RadGrid - Grouping with Merged Row Design aspect

4 posts, 1 answers
  1. Brett
    Brett avatar
    42 posts
    Member since:
    Aug 2014

    Posted 17 Nov 2014 Link to this post

    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.
  2. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 20 Nov 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brett
    Brett avatar
    42 posts
    Member since:
    Aug 2014

    Posted 20 Nov 2014 in reply to Konstantin Dikov Link to this post

    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 .. 



  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 25 Nov 2014 Link to this post

    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.

     
Back to Top