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

row indexon clientside

1 Answer 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dawson
Top achievements
Rank 1
Dawson asked on 03 Dec 2013, 12:51 PM
Hi
i have a radbutton in the itemtemplate of a column. How to get the rowindex of the selected button row on clientside? 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Dec 2013, 01:03 PM
Hi Dawson,

Please try the following code snippet .

ASPX:
<telerik:GridTemplateColumn>
    <ItemTemplate>
        <telerik:RadButton ID="RadButton1" runat="server" Text="RowIndex" OnClientClicked="RowIndexFind" />
    </ItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
  {
      GridDataItem item = e.Item as GridDataItem;
      RadButton Editbtn = item.FindControl("RadButton1") as RadButton;
      Editbtn.Attributes.Add("rowindex", item.ItemIndex.ToString());
  }
}

JS:
<script type="text/javascript">
function RowIndexFind(sender, eventArgs) {
    var radGrid = $find('<%=RadGrid1.ClientID %>');
    var masterTable = radGrid.get_masterTableView(); 
    var row = sender._element.getAttribute("rowindex");// Get Row index
}
</script>

Thanks,
Shinu
Tags
Grid
Asked by
Dawson
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or