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

Multi row selection in grouped grid (or hierarchical grid)

6 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jan
Top achievements
Rank 1
jan asked on 04 Aug 2008, 05:28 PM

Hi,

I need to implement several level nested hierarchy with possibility to check (or select) multiple rows, but also whole groups or sub-groups of rows (let say that for rows of orders for customers from different countries I need to group every orders of each customer together and every customers from each country together and then be able to select multiple orders – one by one or every for selected customers or every for selected country – so that after selecting one subgroup, each row of this sub-group will be selected).

I would like to use grouping for this – but I was not able to simply add check-boxes in header lines.

<telerik:GridGroupByExpression>

        <SelectFields>

            <telerik:GridGroupByField FieldName="countryName" HeaderText=" <input type='checkbox' onClick='CountryRowSelecting()'> " />

        </SelectFields>

        <GroupByFields>

            <telerik:GridGroupByField FieldName="countryId" SortOrder="Descending" HeaderText="Country" />

        </GroupByFields>

</telerik:GridGroupByExpression>

<telerik:GridGroupByExpression>

        <SelectFields>

            <telerik:GridGroupByField FieldName="customerName" HeaderText=" <input type='checkbox' onClick='CustomerRowSelecting()'> " />

        </SelectFields>

        <GroupByFields>

            <telerik:GridGroupByField FieldName="customerId" SortOrder="Descending" HeaderText="Customer" />

        </GroupByFields>

</telerik:GridGroupByExpression>

But then I was not able to properly handle these events, I think there should be some easier way.

I was also trying hierarchical grid (but I would like it with grouping more), but there with multi-rows grouping, when I selected whole category, just one sub-level subcategories was selected (but I need it for each level- e.g. after selecting some country, each order for each customer from this country would be selected).

Does radgrid somehow enable this desired behaving?

Thanks

Jan

6 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 06 Aug 2008, 12:18 PM
Hi jan,

The functionality can most easily be achieved in a hierachical structure. As a starting point, you can use the following example, which shows how to access the different elements of the hierarchy. A similar approach can be used to achieve the effect of selecting the inner level(s) by selecting the master record. Also, attached to this message, is a small working application, which handles a very similar functionality.
I hope this helps.

Greetings,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Le
Top achievements
Rank 1
answered on 13 May 2009, 03:49 AM
Hi,
I got the issue when I add groupby expression in codebehind. It does not have multi-rows grouping, but it show the same row header
    + Column1;Column2;Column3
I need groupby expression like that
    + Column1
          + Column2
                 + Column3
Plz, Help me!
Best regards,

0
Shinu
Top achievements
Rank 2
answered on 13 May 2009, 06:02 AM
Hello Le,

You would have to add seperate expressions to your GroupByExpressions collection to achieve the required. Check out the code below :
c#:
        //First expression  
        GridGroupByExpression expression1 = new GridGroupByExpression();  
        GridGroupByField gridGroupByField1 = new GridGroupByField();    
        
        gridGroupByField1 = new GridGroupByField();  
        gridGroupByField1.FieldName = "FirstName";  
        gridGroupByField1.HeaderText = "FirstName";          
        gridGroupByField1.FormatString = "<strong>{0}</strong>";          
        expression1.SelectFields.Add(gridGroupByField1);  
          
        gridGroupByField1 = new GridGroupByField();  
        gridGroupByField1.FieldName = "FirstName";  
        expression1.GroupByFields.Add(gridGroupByField1);  
  
        //Second expression  
        GridGroupByExpression expression2 = new GridGroupByExpression();  
        GridGroupByField gridGroupByField3 = new GridGroupByField();  
         
        gridGroupByField3 = new GridGroupByField();  
        gridGroupByField3.FieldName = "PlaceFrom";  
        gridGroupByField3.HeaderText = "PlaceFrom";         
        gridGroupByField3.FormatString = "<strong>{0}</strong>";  
        expression2.SelectFields.Add(gridGroupByField3);          
          
        gridGroupByField3 = new GridGroupByField();  
        gridGroupByField3.FieldName = "PlaceFrom";  
        expression2.GroupByFields.Add(gridGroupByField3);  
        // Add the expressions to the GroupByExpressions collection  
        RadGrid1.MasterTableView.GroupByExpressions.Add(expression1);  
        RadGrid1.MasterTableView.GroupByExpressions.Add(expression2);  

Thanks
Shinu.
0
Le
Top achievements
Rank 1
answered on 13 May 2009, 08:15 AM
Thanks, I got it.
0
Mark
Top achievements
Rank 1
answered on 17 May 2010, 02:43 PM
I am attempting to do something very similar with the hierarchy.   The issue is when the second level in the hierarchy bleeds over onto multiple pages - and I select the top level in the hierarchy (select all), I can't get it to select all for items on subsequent pages (even if they are under this main hierarchy level).   This appears to be a bug.  Does telerik offer a workaround?
0
Iana Tsolova
Telerik team
answered on 17 May 2010, 03:42 PM
Hi Mark,

When paging is enable for RadGrid, then the items available in the grid are only these from the current page. Therefore you are able to select only them.
To overcome that issue, you can either disable paging or handle the ItemCommand/PageIndexChanged event to select the items on the new page respectively.

All the best,
Iana
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
jan
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Le
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Mark
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or