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 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" />
    </ClientSettings>

     

    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;
           }
    </script>

     

    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
    Admin
    Eyup avatar
    3005 posts

    Posted 15 Aug Link to this post

    Hi Shawn,

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

    I hope this will prove helpful.

    Regards,
    Eyup
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top