This is a migrated thread and some comments may be shown as answers.

Server Bound MVC Grid

2 Answers 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neil
Top achievements
Rank 1
Neil asked on 16 Aug 2017, 06:29 PM

I can't seem to find the answers to these questions.

 

1) Can you apply a double click to the row when server binding the grid, I've tried the following code in the OnDataBound function but it doesn't execute when double clicking the row?

2) I could also use a custom command button as well instead of the double click, but I can't find a handle to the row when I fire the the following script.

Double Click row script.

$(that.tbody).on("dblclick",
                "tr",
                function (e) {
                    var rowData = that.dataItem(this);
                    CheckForTemplate(rowData.Id);
                });

 

Custom Command button script.

columns.Command(command =>
                      {
                          command.Custom("Datasheet").Click("ViewDatasheet")
                      }).Width(200);
 
function ViewDatasheet(e) {
        e.preventDefault();
        var dataItem = this.dataItem($(e.currentTarget).closest("tr")); -> This line causes the attached script error.
        idcount = dataItem.Id;
        $.ajax({
            type: "POST",
            url: '@Url.Action("CheckForAssignedTemplate", "Data")',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify({ moduleid: @Model.TheModule.Id, idcount: idcount }),
            dataType: "json",
            success: function(result) {
                if (result.datasheetid !== "") {
                    location.href = '@Url.Action("Index", "Datasheet")?datasheetid=' + result.datasheetid;
                } else {
                    var window = $("#window_newDataSheet").data("kendoWindow");
                    window.center().open();
                }
            },
            error: function() {
                $(".validation-summary-valid").text(result.message);
            }
        });
    }

2 Answers, 1 is accepted

Sort by
0
Neil
Top achievements
Rank 1
answered on 16 Aug 2017, 08:15 PM

I figured out a work around. In my case I was trying to find the Id for the row. Here's how I found it.

$(e.target).closest('tr').children('td')[2].innerText

2 = ordinal of the column in the grid row

 

0
Boyan Dimitrov
Telerik team
answered on 18 Aug 2017, 09:52 AM

Hello Neil,

The problem you are facing is that when Kendo UI Grid is server bound the DataSource is empty since there are no client-side operations. All operations are performed on the server only and the Kendo UI DataSource does not contain any data. 

Regards,
Boyan Dimitrov
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Neil
Top achievements
Rank 1
Answers by
Neil
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or