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

Iterating over first columns in a grouped RadGrid

1 Answer 45 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Ed asked on 24 Oct 2016, 01:04 PM

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

1 Answer, 1 is accepted

Sort by
Angel Petrov
Telerik team
answered on 27 Oct 2016, 10:42 AM

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.
Asked by
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question