is it possible to store existing grid events before unbinding them

3 posts, 1 answers
  1. John
    John avatar
    5 posts
    Member since:
    May 2018

    Posted 26 Aug 2020 Link to this post

    I have the pleasure of dealing with the code someone else has written that affects every grid on our site (about 100).  
    Here is the problem. His default "DataBound" event resizes the action column we have at the left of our grids so that it matches the width of the displayed buttons.  Makes sense.  However, he has code in there that when the grid is intiialized, unbinds the current databound event then rebinds it to his special databound event.  It looks like he assumed that this is the only usage we would ever have for databound.

    I discovered this when i created a custom databound on a grid, and it was never called.

    Is there a way to modify this code so that it stores the current databound event and reapplies it?

    gridSelector = gridSelector || "#grid";
    // scoped function that can be assigned to the dataBoundEvent and called directly (below)
    var doGridDataBound = function (me, gridSelector, grid) {
        setTimeout(function () {
        }, 500);
    var grid = $(gridSelector).data("kendoGrid");
    // delay "connecting" the dataBound event handler for 250ms to give time for other event handlers to be assigned first (we need this one to "fire" last)
    // specifically - customKendoButtons_OnDataBound needs to fire earlier than this one to ensure that the buttons are visible/fully defined before "autoFit" is executed
    grid.unbind("dataBound").bind("dataBound", function () {
        doGridDataBound(me, gridSelector, grid);
    /* if any data rows already exist, then the dataBound event will not fire again, so fire it now */
    if ($(gridSelector).find("input.gridPopupHelper").length)
        doGridDataBound(me, gridSelector, grid);

  2. Answer
    Angel Petrov
    Angel Petrov avatar
    1153 posts

    Posted 28 Aug 2020 Link to this post

    Hello John,

    You can differentiate the handlers and unbind the specific one but for that case one should avoid binding to anonymous functions and passe a reference to the handlers when binding/unbinding. Here is a dojo that illustrates this approach and unbinds a specific handler.

    Angel Petrov
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at

  3. John
    John avatar
    5 posts
    Member since:
    May 2018

    Posted 28 Aug 2020 in reply to Angel Petrov Link to this post

    thank you.  This is exactly what i needed.
Back to Top