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

RadGrid - Grouping with Merged Row Design aspect

3 Answers 226 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 1
Brett asked on 17 Nov 2014, 06:03 PM
I'm not sure if the RadGrid (or late bound controls) support what I'm trying to do.

My concern is design in nature.

I can already perform the grouping server-side, but when I have two items that match on a particular DataKey, I need to effectively make them appear as 1 item.

For example:

// Asset of a person
public class PersonAsset {
     public Guid PersonID {get;} //DataKey; second GroupBy will be by PersonID
      
     public string Asset {get;set;}
     public Guid AssetID {get;set} //not a DataKey for the Grid, correlates to a comboxbox that makes the asset changeable
      
     public string PersonName {get;set;}
     public string Note1 {get;set;}
     public string Note2 {get;set;}
     public string Note3 {get;set;}
     public PersonAssetState State {get;set;}
}
 
//going to perform first GroupBy using this enum
public enum PersonAssetState {
   NotSet,
   Type1,
   Type2
}

<telerik:RadGrid runat="server" ID="rGridInventory" ShowHeader="true" Width="99%" OnNeedDataSource="rGridInventory_NeedDataSource">
       <MasterTableView DataKeyNames="PersonID" ClientDataKeyNames="PersonID" 
           ShowGroupFooter="true" GroupLoadMode="Client">
           <GroupFooterTemplate>              
           </GroupFooterTemplate>
           <GroupByExpressions>
               <telerik:GridGroupByExpression>
                   <GroupByFields>
                       <telerik:GridGroupByField FieldName="State" SortOrder="Descending" />
                       <telerik:GridGroupByField FieldName="PersonID" />
                   </GroupByFields>
                   <SelectFields>
                       <telerik:GridGroupByField FieldName="State" />
                       <telerik:GridGroupByField FieldName="PersonID" />
                   </SelectFields>
               </telerik:GridGroupByExpression>
           </GroupByExpressions>
       </MasterTableView>           
   </telerik:RadGrid>

So at this point, instead of having subsequent grouped columns/rows containing "PersonName" twice or more in a tubalar fashion, I am looking for it to display once, and for all groupings at this level (Second) to appear as 1 row.

3 Answers, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 20 Nov 2014, 02:42 PM
Hi Brett,

There is no built-in functionality that will allow you to accomplish such result with RadGrid, because it will display all items that are included in its data source.

You could manually traverse through the items and hide the duplicate items, but I am not sure if this will work for all scenario.

Now, depending on your exact data you may consider using RadPivotGrid instead of RadGrid, but it would be up to you to decide if that control is suitable for you or not.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Brett
Top achievements
Rank 1
answered on 20 Nov 2014, 05:11 PM
I suspect the PivotGrid won't be applicable, but there is certainly a component to it and the 'footer' grouping template aspect of RadGrid that suggests I could extend the control and template a custom row based on an expression/criteria on the data collection, or rather.. hierarchical?.


Hypothentically, I suspect it would be something along the lines of:

<telerik:RadGrid runat="server" ID="rGridInventory" ShowHeader="true" Width="99%" OnNeedDataSource="rGridInventory_NeedDataSource">
       <MasterTableView DataKeyNames="PersonID" ClientDataKeyNames="PersonID"
           ShowGroupFooter="true" GroupLoadMode="Client">
           <GroupFooterTemplate>             
           </GroupFooterTemplate>
           <GroupCustomTemplates>
                <GroupCustomTemplate ID="MyCustomTemplate">
                       <div><%= ((IEnumarable<PersonAsset>)Container.DataItem)[0].PersonName %></div>
                       <table>
                              <tbody>
                                    <tr><th>Asset Name</th></tr>
                                    <tr><td><%= ((IEnumarable<PersonAsset>)Container.DataItem)[0].AssetName</td></tr>
                                    <tr><td><%= ((IEnumarable<PersonAsset>)Container.DataItem)[1].AssetName</td></tr>
                               </tbody>
                       </table>
                </GroupCustomTemplate>
           </GroupCustomTemplates>
           <GroupByExpressions>
               <telerik:GridGroupByExpression>
                   <GroupByFields>
                       <telerik:GridGroupByField FieldName="State" SortOrder="Descending" />
                       <telerik:GridGroupByField FieldName="PersonID" MaxOccurances="1" />
                       <telerik:GridGroupByField FieldName="PersonID" GroupCustomTemplateID="MyCustomTemplate" MinOccurances="2" MaxOccurances="2" />
                   </GroupByFields>
                   <SelectFields>
                       <telerik:GridGroupByField FieldName="State" />
                       <telerik:GridGroupByField FieldName="PersonID" />
                   </SelectFields>
               </telerik:GridGroupByExpression>
           </GroupByExpressions>
       </MasterTableView>          
   </telerik:RadGrid>

I probably wouldn't go through the effort of supporting the markup/schema aspect, but the idea would be something like this. Where the IEnumerable would perhaps be a Query.AsEnumerable .. 



0
Konstantin Dikov
Telerik team
answered on 25 Nov 2014, 09:38 AM
Hi Brett,

Another possible option for achieving the desired result would be to modify your data in such manner, so you can take advantage of our hierarchical grid structure, where you could have your main data key in the parent item and the detail table will display all child items with that parent data key:

Kind Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Brett
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Brett
Top achievements
Rank 1
Share this question
or