Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Kendo Grid Name in an Event Handler

How to pass gridName to the Kendo event handler. .Events(events => events.RequestEnd("requestEndEvent").

I am using Kendo UI version 2014.2.716.

like image 861
Oxon Avatar asked Aug 15 '14 10:08

Oxon


People also ask

What is Databound event in kendo grid?

Fired when the widget is bound to data from its data source. The event handler function context (available via the this keyword) will be set to the widget instance.

What is Pageable in kendo grid?

kendo:grid-pageable-messagesThe text messages displayed in pager. Use this option to customize or localize the pager messages. More documentation is available at kendo:grid-pageable-messages.


1 Answers

Recently I updated Kendo UI and e.sender.options.table.context.id stopped working. I contacted Kendo and here is their response. The following method can be used to pass gridname to any event handler including error handler.

"You are relying on something that is not documented and is not supported. The correct way of passing Grid id to DataSource event handler is as follows:"

.DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Read(read => read.Action("Orders_Read", "Grid"))
        .Events(e => e.RequestStart("requestStartHandler(\"grid\")"))
     )

<script>
    function requestStartHandler(gridName) {
        return function (e) {
            var grid = $("#" + gridName).data("kendoGrid");
            alert("Request Start for grid: " + gridName + ", items length: " + grid.items().length);
        }
    }
</script>
like image 124
Oxon Avatar answered Sep 30 '22 18:09

Oxon