Call Function on DataBound of Every Instance of Widget

1 Answer 7 Views
Grid
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
Lee asked on 24 Jun 2025, 05:43 PM
I have a lot of projects with kendo grids in them. As a matter of practice, I always call the same function on the dataBound event. Instead of adding this every time I initialize a widget, I would like to set it as a default so that any time I initialize a kendo grid, it is already set. I don't want to give up the ability to add additional functions to specific grids though. Is this possible? 

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 27 Jun 2025, 01:41 PM

Hi Lee,

A possible approach would be if you instantiate the Grids with a JSON literal of options, save a base form of that literal and .extend() it with particulars for each instance. This base literal will have the databound handler.

var baseGridConfig = {
            dataBound: function(e) {
                // Common functionality for all grids
                console.log('Default dataBound executed for:', e.sender.element[0].id);
            },
            sortable: true,
            pageable: {
                pageSize: 5,
                buttonCount: 5
            },
            height: 300,
            scrollable: true
        };

Dojo demo: https://dojo.telerik.com/hYnFGlCv

Regards,
Nikolay
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
commented on 27 Jun 2025, 01:58 PM

Thanks. This gives me a start. I'm still going to figure out how to merge the default dataBound event with the custom one so that both fire but I think I can get inventive there.
Tags
Grid
Asked by
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
Answers by
Nikolay
Telerik team
Share this question
or