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

6 posts, 0 answers
  1. Adam
    Adam avatar
    13 posts
    Member since:
    Apr 2008

    Posted 07 Jun 2011 Link to this post

    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
  2. Adam
    Adam avatar
    13 posts
    Member since:
    Apr 2008

    Posted 07 Jun 2011 Link to this post

    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
  3. Rajan
    Rajan avatar
    9 posts
    Member since:
    May 2015

    Posted 18 Sep 2015 Link to this post

    Is there any in-built solution by Telerik?
  4. Adam
    Adam avatar
    13 posts
    Member since:
    Apr 2008

    Posted 18 Sep 2015 in reply to Rajan Link to this post

    No idea, dude. This solution worked for me so I stuck with it.
  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2425 posts

    Posted 23 Sep 2015 Link to this post

    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
  6. Rajan
    Rajan avatar
    9 posts
    Member since:
    May 2015

    Posted 23 Sep 2015 in reply to Konstantin Dikov Link to this post

    Thanks Konstantin. Adams post helped me. However I was just curious to know if there is alternate solution.
Back to Top