Get reference of a link button on the client side

4 posts, 0 answers
  1. Rishi
    Rishi avatar
    43 posts
    Member since:
    Feb 2010

    Posted 23 Jul 2015 Link to this post

    Hi

    I am trying to get the reference of a link button from a template column based the row index. Ideally upon getting the control i want to call the custom command associated with that button on that row. Can you please let me know how to achieve this in the below code.

     

    var row = $find("<%=rgmyGrid.ClientID %>").get_masterTableView().get_dataItems()[rowIndex];
         var   lnkBtn=   row.findcontrol("lBtnMyLinkButton")
            lnkBtn.fireCommand("ReleaseORTakeControl");​

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2251 posts

    Posted 28 Jul 2015 Link to this post

    Hi Rishi,

    If you have a CommandName property set for a LinkButton, the command should be fired automatically when the button is clicked.

    With that said, I am not sure I completely understand the scenario you would like to implement. Would you elaborate in more detail on what is the behavior that you would like to achieve? When are you trying to get reference to the LinkButton control? Please describe what are the requirements and what should be the expected result.

    Regards,
    Viktor Tachev
    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
  3. Rishi
    Rishi avatar
    43 posts
    Member since:
    Feb 2010

    Posted 03 Aug 2015 in reply to Viktor Tachev Link to this post

    It's a bit convoluted, let me explain the complete scenario :-

    1. Every row of the grid has a link button when clicked opens a rad window to take user input.

    2. On close of the rad window the control comes to the window closed client method.

    3. depending on the user input here need to fire the command on the row that the user has clicked the linked button.

    To achieve this i am passing the rowID from the parent page to the radwindow and back to the parentpage using an object. Now using the above mentioned method if i fire the command the command is always getting fired on the 1st row of the grid it wont take into consideration the rowID on which i want it to fire.

     Please let me know if there is a better way to achieve this ?

  4. Eyup
    Admin
    Eyup avatar
    3690 posts

    Posted 06 Aug 2015 Link to this post

    Hello Rishi,

    There are several solutions to this case:

    1. Once you get a reference to the client-side element of the linkButton you can simply call its click() method.

    2. Fire a custom command using the MasterTableView objectand use the ItemCommand event handler of the grid to handle it on code-behind. As an argument, you can pass the rowIndex:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/gridtableview-object/methods/firecommand

    3. You can raise an AJAX request:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/ajax/client-side-programming/overview#ajaxrequestwithtargeteventtarget-eventargument

    Hope this helps. Please try out the suggestions and let me know if they work for you.


    Regards,
    Eyup
    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
Back to Top