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

OnCommand RowIndex ?

3 Answers 230 Views
Grid
This is a migrated thread and some comments may be shown as answers.
fatih ak
Top achievements
Rank 1
fatih ak asked on 28 Jul 2009, 08:43 PM

I am using  a RadGrid in my project and i want to take rowindex in OnCommand (JavaScript) Function . Is it possible or how can i do it ??


<
telerik:RadGrid ID="RadGrid1" runat="server" Width="96%" GridLines="None" Skin="Vista"

 

 

AutoGenerateColumns="False" AllowFilteringByColumn="True" PageSize="13"

 

 

ShowStatusBar="True" OnUpdateCommand="RadGrid1_UpdateCommand"

 

OnInsertCommand="RadGrid1_InsertCommand"

 

 

OnDeleteCommand="RadGrid1_DeleteCommand"

 

OnNeedDataSource="RadGrid1_NeedDataSource"

 

OnItemDataBound="RadGrid1_ItemDataBound"

 

ShowFooter="True"">

 

<MasterTableView DataKeyNames="MuhFisDetayId" AllowMultiColumnSorting="True" Width="100%"

 

 

CommandItemDisplay="Top" EditMode="InPlace" InsertItemDisplay="Top">

 

<Columns>

 

 

<telerik:GridDropDownColumn DataField="HesapId" DataSourceID="LLBLGenProDataSource3"  

 

 

HeaderText="HesapKodu" ListTextField="HesapKodu" ListValueField="HesapId" UniqueName="HesapId">

 

 

 

 

<ItemStyle HorizontalAlign="Left" />

 

 

 

</telerik:GridDropDownColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Alacak" UniqueName="TemplateColumnAlacak"  EditFormColumnIndex="2">

 

 

 

 

 

 

<ItemTemplate>

 

 

 

 

<%# Eval("Alacak")%>

 

 

 

 

 

</ItemTemplate>

 

 

<EditItemTemplate>

 

 

 

 

<telerik:RadNumericTextBox runat="server" ID="tbAlacak" Width="40px" DbValue='<%# Bind("Alacak") %>' DataType="Decimal">

 

 

 

 

 

 

</telerik:RadNumericTextBox>

 

 

 

 

 

 

</EditItemTemplate>

 

 

 

 

 

 

<FooterTemplate>

 

<asp:Label runat="server" ID="lblAlacakToplam" Text="" Font-Bold="true" Font-Names="Verdana" ForeColor="#000000"></asp:Label 

 

</FooterTemplate>

 

 

 

<ItemStyle HorizontalAlign="Left" />

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

<telerik:GridEditCommandColumn UpdateText="Update" UniqueName="EditCommandColumn"

 

 

 

CancelText="Cancel" EditText="Update">

 

 

 

 

<HeaderStyle Width="85px"></HeaderStyle>

 

 

 

 

</telerik:GridEditCommandColumn>

 

 

 

 

<telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" />

 

 

</Columns>

 

 

 

<EditFormSettings CaptionFormatString="{0} Update" CaptionDataField="MuhFisDetayId">

 

 

 

 

<EditColumn ButtonType="ImageButton" />

 

 

 

 

<FormStyle BackColor="#eef2ea" Width="100%" />

 

 

<FormTableStyle CellPadding="2" CellSpacing="0" GridLines="None" />

 

 

<FormTableItemStyle Height="29px" Width="100%" />

 

 

 

</EditFormSettings>

 

 

 

 

</MasterTableView>

 

 

 

 

<ClientSettings>

 

 

<ClientEvents OnCommand="onCommand" />

 

 

 

<Selecting AllowRowSelect="true" />

 

 

 

 

</ClientSettings>
</telerik:RadGrid>

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Jul 2009, 05:39 AM
Hello,

The OnCommand event will be raised for each grid command which is about to be triggered like sorting, paging, filtering, editing, deleting etc. For editing and deleting the " args.get_commandArgument() " will return the rowindex of clicked row.

 
<script type="text/javascript"
function RaiseCommand(sender, args) 
   if(args.get_commandName()== 'Edit'
   {    
        alert(args.get_commandArgument()); 
   } 
   else if(args.get_commandName() == 'Delete'
   {    
        alert(args.get_commandArgument()); 
   }    
</script> 
Note: For sorting " args.get_commandArgument() " will return the ColumnUniqueName and for paging this will return corresponding command argument(s) value(s).

-Shinu.
0
Michael Sumerano
Top achievements
Rank 2
answered on 28 Sep 2009, 03:34 PM
What about when the command is "ExpandCollapse"?  It seems all it has is whether the current state of the row is expanded or collapsed in the event args.  It'd be nice to know what the row index is or have some way to get the data key for the row being expanded.  Is there some way to do this that I am not finding in your demos or documentation?

I'm trying to bind a detail table client-side to a json object, but for the JavaScript call, I need to know the data key for the row being expanded.
0
Nils C.
Top achievements
Rank 1
answered on 09 Aug 2012, 09:23 AM
Hi there,
I know this post is quite old  - but I'm facing the exact same issue. Has there been a solution?

Thanks!
Tags
Grid
Asked by
fatih ak
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Michael Sumerano
Top achievements
Rank 2
Nils C.
Top achievements
Rank 1
Share this question
or