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

[Solved] Grouping with Advanced Data Binding

1 Answer 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 08 Apr 2009, 11:44 PM

I'm trying to enable grouping on a grid that is using NeedDataSource to get a LINQ table.

        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager> 
        <telerik:RadGrid ID="RadGrid1" runat="server"   
            ongroupschanging="RadGrid1_GroupsChanging"   
            onneeddatasource="RadGrid1_NeedDataSource" AllowPaging="true" ShowGroupPanel="true" > 
            <MasterTableView AllowPaging="true" PageSize="100" DataKeyNames="BuildID" > 
                  
            </MasterTableView> 
            <ClientSettings AllowDragToGroup="true" /> 
        </telerik:RadGrid> 
     protected void RadGrid1_GroupsChanging(object source, Telerik.Web.UI.GridGroupsChangingEventArgs e)  
        {  
 
        }  
 
        protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)  
        {  
            RadGrid1.DataSource = new DataClasses1DataContext().DataTable;  
        } 

When they drag a header to be grouped, GroupsChanging and NeedDataSource both fire. During GroupsChanging, if I get RadGrid1.MasterTableView.GroupExpressions, as expected the group has not been added.

However, during NeedDataSource, the group has not been added to RadGrid1.MasterTableView.GroupExpressions.

When they drag a header to be ungrouped, both events fire again. During GroupsChanging, the group has not been removed, as expected.

During NeedDataSource it has been removed.

So when you're grouping, NeedDataSource does not have the correct grouping information, and when you're ungrouping, it does.

The "DataTable" has about 30 columns and 12,000 rows.
The version on my Telerik.Web.UI is 2008.2.826.35, and the Runtime Version is v2.0.50727.

The reason I need grouping info during NeedDataSource is because I'm trying to keep Custom Paging after they group headers by doing my own sorting on the LINQ table.

Thanks,
John

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 13 Apr 2009, 09:02 AM
Hello John,

You should use the GridGroupsChangingEventArgs object in the handler for the GroupsChanging event to extract the current grouping expression. 

Best Regards,
Tsvetoslav
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or