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

Select grid row on button click using client side

4 Answers 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ali zubair
Top achievements
Rank 1
ali zubair asked on 28 May 2010, 02:59 PM
HI All,
I am badly struck with an issue that i want to select a row of telerk grid on button click. but on client  side. i don not want to go server side. i am unable to do it.

I have tried many things like
on Client events i add OnRowSelected="RowSelected"
and
following code add check box in all row.
 <Columns>
     <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
</Columns>


but i can not do it on button click.
so Is it possible and if yes then kindly help me.

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 May 2010, 03:23 PM
Hello,

One suggestion would be placing button in ItemTemplate and attaching the client side click event to buttons in ItemCreated event and pass the index to handler. Then in the client click event handler, get reference to dataitem and use the set_selected() method to select it.

-Shinu.
0
ali zubair
Top achievements
Rank 1
answered on 28 May 2010, 03:28 PM
Thanks for your reply.
But can you please elaborate it. it seems logical but how can i actually implement it.

Thanks.
0
ali zubair
Top achievements
Rank 1
answered on 28 May 2010, 04:09 PM
What i actually want is that

I have bind grid using web service and now i want to get the id of selected row on button click.

i got this id on row selected but cannot get it on button click. how can i do this. but on client side.
0
Princy
Top achievements
Rank 2
answered on 01 Jun 2010, 10:39 AM
Hello ali,

Try the following code snippet and see whether it helps you.

ASPX:
<MasterTableView Name="Master" DataKeyNames="EmployeeID" ClientDataKeyNames="EmployeeID"
........ 
  <asp:Button ID="Button2" runat="server" Text="Button" OnClientClick="ButtonClick();" /> 

Java Script:
<script type="text/javascript"
    function ButtonClick() 
    { 
        var grid = $find("<%=RadGrid1.ClientID %>"); 
        var masterTable = grid.get_masterTableView(); 
        for (var i = 0; i < masterTable.get_selectedItems().length; i++) 
        { 
            var row = masterTable.get_selectedItems()[i]; 
            var id = row.getDataKeyValue("EmployeeID");//get the key value 
        } 
     } 
</script> 
 

Thanks,
Princy.



Tags
Grid
Asked by
ali zubair
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
ali zubair
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or