How to pass gridName to the Kendo event handler. .Events(events => events.RequestEnd("requestEndEvent")
.
I am using Kendo UI version 2014.2.716.
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With