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

[HELP] client select column in RadGrid

3 Answers 235 Views
Grid
This is a migrated thread and some comments may be shown as answers.
trunghieu
Top achievements
Rank 1
trunghieu asked on 12 Apr 2011, 06:44 PM
Hello all,i have a problems with Radgrid,plz help me
i want when i click client select column on my grid then informations on a row binding to textbox
example : 
http://nguy-hiem.co.cc/img.png
So what should i do ? what the event i can use ?

THANK !

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Apr 2011, 06:04 AM
Hello Trunghieu,

You could attach the ClientEvent OnRowSelecting and can access the required column value as shown below.
ClientSide:
function OnRowSelecting(Sender, agrs)
    {
       var value=agrs.get_gridDataItem().get_cell("LastName").innerText;//accessing the column value
       var textBox = document.getElementById("TextBox1");
       textBox.innerText = value;
   }

 Corresponding aspx is:
<MasterTableView. . . . . >
    <Columns>
 <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
 <telerik:GridBoundColumn HeaderText="LastName" DataField="LastName" UniqueName="LastName">
 </telerik:GridBoundColumn>
    </Columns>
</MasterTableView>
<ClientSettings ClientEvents-OnRowSelecting="OnRowSelecting">
    <Selecting AllowRowSelect="true" />
</ClientSettings>

Thanks,
Shinu.
0
trunghieu
Top achievements
Rank 1
answered on 14 Apr 2011, 09:51 AM
Hix, your code not run @@
can you help me plz,i have another opinion
http://nguy-hiem.co.cc/chan.png

when i click to small button in this image(that's asp img button) , so , how to get row index of gridview or even get infomation of column HọTê n?

THANK
0
Shinu
Top achievements
Rank 2
answered on 18 Apr 2011, 07:04 AM
Hello Trunghieu,

You can attach 'onclick' client event to ImageButton and pass the row index to client side event handler. And in the event handler access the row using following code snippet.

ASPX:
<Columns>
     <telerik:GridTemplateColumn>
        <ItemTemplate>
            <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/Edit.gif" />
        </ItemTemplate>
    </telerik:GridTemplateColumn>
</Columns>

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem)
       {
           GridDataItem item = (GridDataItem)e.Item;
           ImageButton btn = (ImageButton)item.FindControl("ImageButton1");
           btn.Attributes.Add("onclick", "btnClick('"+ item.ItemIndex+"');");
       }
   }

Java Script:
<script type="text/javascript">
      function btnClick(index) {
        var grid = $find("<%=RadGrid1.ClientID %>");
        debugger;
        var MasterTable = grid.get_masterTableView();
        var row = MasterTable.get_dataItems()[index];//getting corresponding row
    }
</script>

-Shinu.
Tags
Grid
Asked by
trunghieu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
trunghieu
Top achievements
Rank 1
Share this question
or