Iterating over first columns in a grouped RadGrid

2 posts, 0 answers
  1. Ed
    Ed avatar
    4 posts
    Member since:
    Sep 2013

    Posted 24 Oct 2016 Link to this post

    I have a RadGrid in which i need to loop through the first column and turn off the on click event.  

    Prior to grouping this RadGrid the following code did this across each individual row.

    CType(CType(Page.Form.FindControl("ReportGrid"), RadGrid).MasterTableView.Items(i).Cells(2), TableCell).Attributes.Add("OnClick", "return false;")


    CType(Page.Form.FindControl("ReportGrid"), RadGrid).MasterTableView.Items(lastRowCount - j).CssClass = "boldRow" 

    over the last row in order to bold the sum row. 


    However now with grouping I cannot locate the appropriate position to set the attribute/cssclass.  Also the total row for each group is duplicated twice. 

    How do I access the first column in each row turn off the OnClick event? And how do I find/access the last row of each group? 

    thank you. 

    <telerik:RadGrid ID="ReportGrid" runat="server" AllowSorting="True" AutoGenerateColumns="False"
    Skin="Rental" PageSize="100000" GridLines="None" Width="930px" AllowPaging="True"
    TabIndex="-1" EnableEmbeddedSkins="false" Height="480px" >
    <PagerStyle Position="Bottom" Mode="NumericPages" PageButtonCount="10" AlwaysVisible="true" />
    <Scrolling UseStaticHeaders="True" AllowScroll="True" ScrollHeight="430px"></Scrolling>
    <Resizing ResizeGridOnColumnResize="True" ClipCellContentOnResize="False" />
    <SortingSettings EnableSkinSortStyles="false" />
    <MasterTableView AllowCustomSorting="true" AllowMultiColumnSorting="false" EnableNoRecordsTemplate="False" GridLines="Vertical" DataKeyNames="regionid" TableLayout="Fixed">
    <telerik:GridSortExpression FieldName="Product" SortOrder="Ascending" />
    <telerik:GridGroupByField FieldAlias="Product" FieldName="Product" SortOrder="Ascending"></telerik:GridGroupByField>
    <telerik:GridGroupByField FieldName="ProductSort" SortOrder="Descending"></telerik:GridGroupByField>
    There is no data to display.
    <telerik:GridButtonColumn ButtonType="LinkButton" ImageUrl="" HeaderText="Region"
    DataTextField="RegionName" ItemStyle-CssClass="GrdBtn" CommandName="Select" UniqueName="btnSelect" SortExpression="Name"
    HeaderStyle-Width="150px" />
    <telerik:GridBoundColumn DataField="Size" HeaderText="Size" UniqueName="Size"
    <HeaderStyle Width="60px" />
    <telerik:GridBoundColumn DataField="Util" HeaderText="Util" UniqueName="Util"
    <HeaderStyle Width="60px" />
    <telerik:GridBoundColumn DataField="Lol" HeaderText="Lol" UniqueName="Lol"
    <HeaderStyle Width="60px" />
    <telerik:GridBoundColumn DataField="ConLength" HeaderText="ConLength over Time" UniqueName="ConLength"
    <HeaderStyle Width="60px" />

  2. Angel Petrov
    Angel Petrov avatar
    1152 posts

    Posted 27 Oct 2016 Link to this post


    Accessing the column cells is possible by setting a UniqueName for the column and doing the following.
    CType(CType(Page.Form.FindControl("ReportGrid"), RadGrid).MasterTableView.Items(i)("thecolumnuniquename"), TableCell).Attributes.Add("OnClick", "return false;")

    As for adding a class for the last row in the group on the server I have to say that this would be difficult. However you can easily achieve this on the client using jQuery. An exemplary implementation is provided below.
    function pageLoad() {
        $telerik.$(".rgRow,.rgAltRow").each(function () {
            var that = this;
            if (that.nextSibling.className && that.nextSibling.className.indexOf("rgGroupHeader") !== -1) {
            if (!that.nextSibling.className && $telerik.$(".rgGroupHeader").last().text().indexOf("continues") == -1) {

    Angel Petrov
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Back to Top