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

How to get column name from filter template control's JS event?

5 Answers 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 07 Jun 2011, 11:15 AM
Hi,

I currently have a couple of RadDatePickers in a GridBoundColumn's FilterTemplate section.  I'm using the ClientEvents-OnDateSelected on both RadDatePickers to call a JavaScript function.  

ClientEvents-OnDateSelected="DateSelected"
 
function DateSelected(sender, args) {
   ...
}


In the JavaScript event that's called by the RadDatePickers I need the name of the column that the RadDatePicker which called the event is in.  Any idea how I can get this?

Cheers,

Adam

5 Answers, 1 is accepted

Sort by
0
Adam
Top achievements
Rank 1
answered on 07 Jun 2011, 11:35 AM
In my example I am extending the GridBoundColumn class and the following solution works for me:

I added a custom attribute to the RadDatePickers called "ParentColumName".

fromDatePicker.Attributes.Add( "ParentColumnName", this.UniqueName );

I pick this up in the JS event as follows:

var parentColumnName = sender.get_element().parentNode.getAttribute('ParentColumnName');

I can then use the column name to fire off this particular column's filters etc.

Adam
0
Rajan
Top achievements
Rank 1
answered on 18 Sep 2015, 10:57 AM
Is there any in-built solution by Telerik?
0
Adam
Top achievements
Rank 1
answered on 18 Sep 2015, 11:24 AM
No idea, dude. This solution worked for me so I stuck with it.
0
Konstantin Dikov
Telerik team
answered on 23 Sep 2015, 06:39 AM
Hello Rajan,

Since this is a control within a template (the FilterTemplate), RadGrid could not have any control over the content of that template, which is the reason that there could not be a built-in way for retrieving the column name from within a client-side event of the filter control. However, the approach that Adam is using is simple enough and should help you achieve the desired result. 


Best Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Rajan
Top achievements
Rank 1
answered on 23 Sep 2015, 05:09 PM
Thanks Konstantin. Adams post helped me. However I was just curious to know if there is alternate solution.
Tags
Grid
Asked by
Adam
Top achievements
Rank 1
Answers by
Adam
Top achievements
Rank 1
Rajan
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or