Accessing Proper Row From OnCommand With Collapsed Group Row

2 posts, 0 answers
  1. Shawn R.
    Shawn R. avatar
    4 posts
    Member since:
    Nov 2008

    Posted 10 Aug 2016 Link to this post

    I have a GridButtonColumn with ButtonType="ImageButton". I'm accessing the button click client side with OnCommand of the RadGrid.

    <ClientSettings >
       <ClientEvents OnCommand="OnCommand" />


    I know I can get the row through args.get_commandArgument(), but this is the row of the Master Table and works fine if my grouped table doesn't have a collapsed grouping, but fails horribly when there is a collapsed group.


    <script type="text/javascript">
        function OnCommand(sender, args) {
            var rowIndex = args.get_commandArgument(); // getting row index
            var itemValue = masterTable.getCellByColumnUniqueName(masterTable.get_dataItems()[row], "itemName").innerHTML;


    For example, the rowIndex is determined to be 20 and and there are no collapsed rows so masterTable.getCellByColumnUniqueName(masterTable.get_dataItems()[row], "itemName").innerHTML return the correct row and value. But say a group above has 10 rows collapsed then the 20 referes to something 10 down the table. The rowIndex value in this instance needs to be 10. 


    So . . . what am I doing wrong. How to account for the collapsed rows? Should I be doing this differently?


    TIA - Shawn

  2. Eyup
    Eyup avatar
    4045 posts

    Posted 15 Aug 2016 Link to this post

    Hi Shawn,

    You can try the following alternative approach:
    <telerik:GridTemplateColumn UniqueName="TemplateColumnName">
            <asp:ImageButton ID="ImageButton1" runat="server" AlternateText="ImageButtonCommand"
                OnClientClick='<%# "imageButtonClick(\""+Eval("ShipName")+"\"); return false;" %>' />
    function imageButtonClick(shipName) {
        var masterTable = $find('<%= RadGrid1.ClientID %>').get_masterTableView();
        masterTable.fireCommand("ImageButtonCommand", shipName);

    I hope this will prove helpful.

    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top