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

Dynamic grouping in radgrid dynamic column

5 Answers 627 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jignesh
Top achievements
Rank 1
Jignesh asked on 30 Apr 2010, 03:07 PM
Hello Friends,

I have one page in that i created dynamically bound column and bind it to radgrid.

I need to apply grouping dynamically.

When i try to apply grouping than i got the below error.jpg(attachment) error.

Below is my .aspx code

<radG:RadGrid ID="dgVendorLists" runat="server" AllowSorting="True" AllowPaging="true"
            GroupPanel-Text="Drag and Drop Column Header To Regroup Column. " EnableAJAX="False"
            AllowFilteringByColumn="True" ShowGroupPanel="True" ExportSettings-ExportOnlyData="true"
            ExportSettings-IgnorePaging="true" ExportSettings-OpenInNewWindow="true" ShowFooter="false"
            Skin="Monochrome" BorderStyle="None" MasterTableView-CellPadding="0" EnableAJAXLoadingTemplate="False"
            GridLines="both" ClientSettings-ApplyStylesOnClient="true" Width="100%" PageSize="19" GroupingEnabled="true">
            <PagerStyle Mode="NumericPages" />
            <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="None" GroupLoadMode="Server"
                EnableColumnsViewState="true" TableLayout="Fixed">
                <ExpandCollapseColumn Visible="False">
                    <HeaderStyle Width="19px" />
                </ExpandCollapseColumn>
                <RowIndicatorColumn Visible="False">
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                <Columns>
                </Columns>
            </MasterTableView>
            <ClientSettings EnableClientKeyValues="True" ReorderColumnsOnClient="True" AllowColumnsReorder="True"
                AllowGroupExpandCollapse="True" AllowDragToGroup="True">
                <Resizing AllowColumnResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="False" />
                <Selecting AllowRowSelect="true" />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" ScrollHeight="405px">
                </Scrolling>
            </ClientSettings>
            <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle>
        </radG:RadGrid>



Below is my .vb code.

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
        CreateTempUserTable()
         End If
    End Sub
    Private Sub CreateTempUserTable()
        ViewState("dtUser") = Nothing
        Dim dt As New DataTable
        dt.Columns.Add("name")
        dt.Columns.Add("Companyid")
        Dim dr As DataRow
        Dim i As Integer
        For i = 0 To 10
            dr = dt.NewRow()
            dr("name") = "Test" & i
            If i = 0 Or i = 2 Or i = 4 Or i = 8 Then
                dr("Companyid") = "10"
            Else
                dr("Companyid") = "20"
            End If
            dt.Rows.Add(dr)
        Next

        Dim boundName As New GridBoundColumn
        boundName.AllowFiltering = True
        boundName.DataField = "name"
        boundName.HeaderText = "name"
        boundName.HeaderText = "name"
        boundName.GroupByExpression = "name"
        boundName.Groupable = True

        dgVendorLists.MasterTableView.Columns.Add(boundName)
        Dim boundCompanyId As New GridBoundColumn

        boundCompanyId.AllowFiltering = True
        boundCompanyId.DataField = "Companyid"
        boundCompanyId.HeaderText = "Companyid"
        boundCompanyId.UniqueName = "Companyid"
        boundCompanyId.SortExpression = "Companyid"
        boundCompanyId.Display = True
        boundCompanyId.Groupable = True
        boundCompanyId.GroupByExpression = "Companyid"
        dgVendorLists.MasterTableView.Columns.Add(boundCompanyId)
        dgVendorLists.DataSource = dt
        dgVendorLists.DataBind()
        ViewState("dt") = dt
    End Sub
    Protected Sub dgVendorLists_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles dgVendorLists.NeedDataSource
       Me.dgVendorLists.DataSource = ViewState("dt")
    End Sub
 
    Protected Sub dgVendorLists_Grouping(ByVal source As Object, ByVal e As Telerik.WebControls.GridGroupsChangingEventArgs) Handles dgVendorLists.GroupsChanging
        Dim expression As GridGroupByExpression = New GridGroupByExpression
        Dim gridGroupByField As GridGroupByField = New GridGroupByField
        gridGroupByField = New GridGroupByField
        gridGroupByField.FieldName = "Companyid"
        expression.GroupByFields.Add(gridGroupByField)
        dgVendorLists.MasterTableView.GroupByExpressions.Add(expression)
        dgVendorLists.Rebind()
    End Sub

Please help me where i am wrong and how to implement grouping dynamically with dynamic column.


Thanks & Regards
Jignesh Patel

5 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 30 Apr 2010, 03:43 PM
Hello,

The grouping feature of RadGrid is not supported with simple binding and DataBind() calls. This is outlined in the Description section of the following online demo of the product:
http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/outlookstyle/defaultcs.aspx

If you would like to take advantage of this grid feature, you will need to switch to advanced binding using NeedDataSource event handling or a data source control (as shown in the example linked above).

Best wishes,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jignesh
Top achievements
Rank 1
answered on 03 May 2010, 02:33 PM
Hello Pavlina,

Thanks for reply.

i had tried with first add dynamic column and than set the other property so its working fine with my test page.
But i need to apply it in another page which have some complex code. i had done same thing as per my test page.
When i applied grouping on any column than i get the group record with only group row name. not getting any record inside the group.
Pls find the attachment. In that i have applied grouping on "Urgent" column which contain record text "Yes" , "No" when i applied grouping on that than i get it in group but not getting any data inside group.


Can u tell me where is the problem.

Thanks & Regards
Jignesh Patel

0
Pavlina
Telerik team
answered on 05 May 2010, 03:05 PM
Hi Jignesh,

Based on this information, it is hard to determine what is causing this behavior.
If the issue persists, you can open a formal support ticket, and send us a small project, demonstrating your logic, as well as the problem you are facing, for additional local testing.

All the best,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jignesh
Top achievements
Rank 1
answered on 07 May 2010, 10:53 AM
Hello Pavlina

Thaks for your support.

http://www.telerik.com/community/forums/aspnet-ajax/grid/grouping-with-custom-pagging-and-dynamic-column.aspx



Here i post my sample code for .aspx,.vb and Stored Procedure.

Please use that code and run it. and where is i am wrong.

Please help me.

Thanks & Regards
Jignesh Patel

0
Pavlina
Telerik team
answered on 12 May 2010, 01:44 PM
Hello Jignesh,

To avoid duplicate posts, we will continue our communication in the other forum post that you have opened on the matter. I have already answered your other ticket with the same question.

Best wishes,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Jignesh
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Jignesh
Top achievements
Rank 1
Share this question
or