Normal 0 false false false EN-US X-NONE X-NONE
I have a WebDataGrid with a bunch of bound data fields and a template field with image buttons in them.
<ig:TemplateDataField Key="Buttons" Width="185px">
<ItemTemplate>
<igtxt:WebImageButton ID="btnApprove" runat="server" Text="Approve" CommandName="Approve" CommandArgument=<%#Eval("ID")%> Width="55px" ><ClientSideEvents Click="btnApprove_Click" /></igtxt:WebImageButton>
<igtxt:WebImageButton ID="btnReject" runat="server" Text="Reject" CommandName="Reject" CommandArgument=<%#Eval("ID")%> Width="55px"></igtxt:WebImageButton>
<igtxt:WebImageButton ID="btnTerminate" runat="server" Text="Terminate" CommandName="Terminate" CommandArgument=<%#Eval("ID")%> Width="65px"></igtxt:WebImageButton>
</ItemTemplate>
</ig:TemplateDataField>
When one of the buttons is clicked I would like to fire off a JavaScript function and capture the current row information and then disable the buttons in the row.
var grid;
function Grid_Initialize(sender, eventArgs)
{
grid = sender;
}
function btnApprove_Click(oButton, oEvent)
var aRow = grid.get_behaviors().get_activation().get_activeCellResolved().get_row();
var iID = aRow.get_dataKey();
alert(iID );
But when I try to get the active row from the grid it seems like it is not always set.
How do I get the row id of the current row.
Thanks
Hi mhussain,
I cant see from the snippet how the selection behavior is configured on your case, but I suggest you to use the following:
<ig:Selection RowSelectType="Single" CellClickAction="Row"/>
Here is the code you can use in your handler to get the selected row.
19 //Get instance of the WebDataHrid on the client
20 var grid = $find('<%= this.WebDataGrid1.ClientID %>');
21 //Get selected rows collection
22 var selectedRows = grid.get_behaviors().get_selection().get_selectedRows();
23 //Get the selected row(the first and only in the collection)
24 var currecnt = selectedRows.getItem(0);
Hope that helps,
am using your code for getting the value of selected row but we are getting error on line number 22 the error is Uncaught TypeError: grid.get_behaviors is not a function
Ashish,
Have you verified that the grid is a valid object? If you are using the incorrect id, this may not be the instance of the grid and that could cause this behavior.