Server Bound MVC Grid

3 posts, 0 answers
  1. Neil
    Neil avatar
    32 posts
    Member since:
    Aug 2016

    Posted 16 Aug 2017 Link to this post

    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. Neil
    Neil avatar
    32 posts
    Member since:
    Aug 2016

    Posted 16 Aug 2017 in reply to Neil Link to this post

    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

     

  3. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 18 Aug 2017 Link to this post

    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.
Back to Top