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

Get reference of a link button on the client side

3 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rishi
Top achievements
Rank 1
Rishi asked on 24 Jul 2015, 03:28 AM

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");​

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 28 Jul 2015, 10:18 AM
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
0
Rishi
Top achievements
Rank 1
answered on 03 Aug 2015, 03:13 PM

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 ?

0
Eyup
Telerik team
answered on 06 Aug 2015, 11:28 AM
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
Tags
Grid
Asked by
Rishi
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Rishi
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or