0

I cannot get my Edit popup window to fire. I don't see any events happening when I debug the application. My add user function works quite well. I believe I have initialized everything correctly -- does anyone see what I did wrong or why it is not initializing correctly?

Any ideas why this is?

@(Html.Kendo().Grid<Areas.Admin.ViewModels.UserManagement.UserManagementVM>()
            .Name("UserProfileGrid")
            .Resizable(c => c.Columns(true))
            .Selectable()
            .Filterable()
            .Groupable()
         .ToolBar(toolbar =>
                {
                    toolbar.Template(@<text>


                        <input id="ButtonAddUser" type="button" class='k-button k-grid-add' value="Add User"/>
                        <input id="ButtonEditUser" type="button" class="k-button k-grid-edit" value="Edit user" />

                    @(Html.Kendo().Button()
                    .Name("ButtonRefreshPage")
                    .HtmlAttributes(new { type = "k-button" })
                    .Icon("history")
                    .Content("Refresh Page")
                    .Events(x => x.Click("RefreshPage")))

                    @(Html.Kendo().Button()
                    .Name("ButtonDeleteUser")
                    .HtmlAttributes(new { type = "k-button" })
                    .Icon("history")
                    .Content("Delete a user")
                    .Events(x => x.Click("DeleteUser")))

                    @(Html.Kendo().Button()
                    .Name("ButtonAbout")
                    .HtmlAttributes(new { type = "k-button" })
                    .Icon("history")
                    .Content("About")
                    .Events(x => x.Click("aboutButtonClick")))
                    </text>);
                })

                .Editable(editable => editable.Mode(GridEditMode.PopUp)
                )

                .Columns(columns =>
                {
                    //columns.Bound(e => e.UserOrg).Width(25).Title("User Organization");
                    columns.Bound(e => e.IsApproved).Width(50).Title("Approved Status");
                    columns.Bound(e => e.UserName).Width(150).Title("User Name");
                    //columns.Bound(e => e.user).Width(150);
                    columns.Bound(e => e.EmailAddress).Width(150).Title("Email Address");
                })

                .Sortable()
                .Scrollable()
                .Pageable()
                .Filterable()
                .Selectable()
                .Events(e =>
                {
                  e.Change("packageRowSelectionChanged");
                })
                .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(20)
                .Events(E => E.Error("error_handler"))
                .Model(model => model.Id(e => e.UserId))
                .Read(read => read.Action("ReadUsers", "UserManagement"))
                .Create(create => create.Action("UserProfileCreator", "UserManagement"))
                .Update(update => update.Action("UserProfileCreator", "UserManagement"))
                .Destroy(destroy => destroy.Action("EditingPopUp_Destroy", "UserManagement"))
                ))
8
  • You are using the same action for Create and Update. That could be the problem.
    – ataravati
    Feb 2, 2015 at 19:59
  • Not the problem -- it doesn't even send a request to the controller.
    – cyclical
    Feb 2, 2015 at 20:21
  • The request is not sent to the controller until after you make updates and click the update button on the pop-up window. You may want to try changing the Update action. They can't be the same, anyway. Even if this issue is not fixed, you will change the update action anyway, right?
    – ataravati
    Feb 2, 2015 at 20:45
  • By the way, what version of Kendo are you using?
    – ataravati
    Feb 2, 2015 at 20:51
  • Interesting -- okay. Yes, of course it will change. I was trouble shooting everything and must have forgotten to switch it back. Just getting the popup window to initialize is the big problem. Not sure what version -- is there a way for me to check?
    – cyclical
    Feb 2, 2015 at 21:10

2 Answers 2

0

Two workarounds:

A: You can create a button and link it to another (hidden button) that will call the (native) edit function, or utilize the editRow command as demonstrated here:

 function startEditUser() {

        var grid = $("#UserProfileGrid").data("kendoGrid");

        var selectedRow = grid.select();
        grid.editRow(selectedRow);

I hope this helps someone out!

4
  • This is totally unnecessary. You are doing something wrong. There's no need for a workaround.
    – ataravati
    Feb 6, 2015 at 2:00
  • Nope -- this is the correct way of doing it, as verified by Telerik themselves. The Grid edit function normally resides inrow and not on the toolbar. In order to have a toolbar edit function, you must use the editRow func.
    – cyclical
    Feb 6, 2015 at 14:24
  • I just realized your Grid doesn't have an Edit command. You don't need that extra function. Just add the Edit command. Check my answer.
    – ataravati
    Feb 6, 2015 at 15:40
  • That provides an "inline" edit -- not a toolbar edit command, which is what our specs called for.
    – cyclical
    Feb 6, 2015 at 18:37
0

You don't have an Edit command in your columns. Of course, that's why the Edit function doesn't work. You can't add the Edit and Delete commands to the toolbar. Add the command to the Columns section in your grid like this:

.Columns(columns =>
{
    //columns.Bound(e => e.UserOrg).Width(25).Title("User Organization");
    columns.Bound(e => e.IsApproved).Width(50).Title("Approved Status");
    columns.Bound(e => e.UserName).Width(150).Title("User Name");
    //columns.Bound(e => e.user).Width(150);
    columns.Bound(e => e.EmailAddress).Width(150).Title("Email Address");
    columns.Command(command => { command.Edit(); command.Destroy(); });
})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.