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

Grid - dynamically change grouping

1 Answer 480 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Royalty Free Sounds -
Top achievements
Rank 1
Royalty Free Sounds - asked on 09 Mar 2017, 10:12 AM

I have the following switch that retrieves the group by dropdown selected value:

 

                  switch (groupValue) {
                case "1":
                    groupField = { field : "GroupByEvent"};
                    break;
                case "2":
                    groupField = { field: "GroupByHorse" };
                    break;
                case "3":
                    groupField = { field: "ProductName" };
                      alert(groupField.field);
                    break;
                case "4":
                    groupField = {field: "GroupByPaymentMethod"};
                    brak;
                default:
                    groupField = { field: null };
                    break;
                      
            }

 

how can I change the kendo grid group by according to the case? (default means no grouping)

 

 $("#grid").kendoGrid({
                        dataSource: {
                            transport: {
                                read: {
                                    url: "https://demos.telerik.com/kendo-ui/service/Products",
                                    dataType: "jsonp"
                                }
                            },
                            pageSize: 5,
                         
                            group: {
                                groupField ???
                            }
                         },

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 10 Mar 2017, 02:49 PM
Hello,

If I understand your requirement correctly, you will be able to apply a group expression dynamically if you use the DataSource group method:

gridInstance.dataSource.group({field: groupField});

Let me know if your question was referring to something else.

Regards,
Tsvetina
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Royalty Free Sounds -
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or