This is a migrated thread and some comments may be shown as answers.

Override DataBound event

5 Answers 389 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
jwize
Top achievements
Rank 1
jwize asked on 27 Jan 2015, 06:40 AM
I have an application that has many grids in it.
Basically, a single script needs to be called every time dataBound has been called without exception. 
How can I accomplish this?
It would be nice to be able to override the dataBound event for all the grids.
A simple solution would be a chain where my method would call the base implementation.

5 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 28 Jan 2015, 04:49 PM
Hi Jaime,

You can try achieving the desired behavior in several ways:

- create a custom widget, which inherits from the Grid and subscribe to dataBound in its init method.
http://docs.telerik.com/kendo-ui/framework/widgets/create-custom-kendo-widget

- locate all Grids on the page, e.g. by their .k-grid CSS class, and subscribe to the dataBound event after widget initialization
http://docs.telerik.com/kendo-ui/basics/events-and-methods#bind-to-events-after-widget-initialization

- use jQuery.extend() to apply "partial" reusable and identical settings to all Grids. The benefit will be that these reusable settings will be defined in one place only

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
jwize
Top achievements
Rank 1
answered on 28 Jan 2015, 06:41 PM
The easiest is probably the jQuery for all the $(".k-grid") thought of that but I have a lot of late binding stuff so it is not ideal. I also use mvc extensions it is also unlikely that the first option will be easy to implement. That means the last might be an option. Is there an example of this(use jQuery.extend() to apply "partial" reusable and identical settings to all Grids) that I can look at? 
0
Dimo
Telerik team
answered on 29 Jan 2015, 03:08 PM
Hi Jaime,

This is a "non wrapper" Kendo UI forum section, and my suggestions were provided with this idea in mind. If you are using the MVC wrappers of Kendo UI, options (1) and (3) are not applicable at all.

It is possible to reuse configuration options with the MVC wrappers by using a custom HtmlHelper:

http://www.telerik.com/forums/define-a-custom-html-kendo-extension-helper#XL7GVFpsXU2CcCIxxKHNBg

Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
jwize
Top achievements
Rank 1
answered on 29 Jan 2015, 10:17 PM
Are you suggesting that I can't override the default scripts ? I am sure that wrappers use the same kendo ui scripts which would mean this is not a wrapper specific question. The example you have linked in the previous post is straight forward yet doesn't answer my question. I use both types of grids. I need to override the kendo ui client-script somehow. 
0
Dimo
Telerik team
answered on 30 Jan 2015, 09:46 AM
Hello Jaime,

You can always edit the Kendo UI source Javascript, even when using server wrappers, but this is not what I was suggesting.

When you are using the Kendo UI server wrappers, you are basically using server-side code to generate the client-side Javascript initialization statement for a particular widget. As a result, you do not have direct control over the generated initialization stament. Options (1) and (3) from my first reply require you to intialize the Kendo UI widgets with Javascript code, which you have written yourself and which is not generated by wrappers. That's why these options are not compatible with server wrappers.

I hope this throws some more light on the topic.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
jwize
Top achievements
Rank 1
Answers by
Dimo
Telerik team
jwize
Top achievements
Rank 1
Share this question
or