I have a databound event that is used on grid but also on a treelist (at first it was grid). Is there a way to determine the type of the e.sender?
1 Answer, 1 is accepted
0
Accepted
Martin
Telerik team
answered on 31 Jan 2022, 02:05 PM
Hello, Dan,
As both the TreeList and the Grid have their own dataBound event, the e.sender will always be the widget that is triggering the event. Could you please let me know if I am missing something from the question?
You are missing exactly the question. Determine the type of the sender (if it is a Tree or a Grid)
Example
functiondataBound(e) {
console.log(typeof e.sender); // this is objectif (e.sender ?? TreeList) {
console.log("The event was triggered for a TreeList");
} elseif (e.sender ?? Grid) {
console.log("The event was triggered for a Grid");
}
}
I am using the same event cause the functionality should be the same but it seems that the 2 controls do not behave in the same way so for a TreeList I have to do some more work in order to have the same functionality as for a grid.
Martin
Telerik team
commented on 01 Feb 2022, 09:33 AM
You can whether the e.sender.options.name is "TreeList" or "Grid". Here is a small example for reference.