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

Programmatically Show Column & Group by another Column

2 Answers 272 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 21 Oct 2013, 08:22 PM
I would like to create a button that when clicked, programmatically shows a column that is previously hidden, and then groups by a specific column...  Psudo code might be...

1.) Button Click
2.) Show Column called "City"
3.) Group by "State".

Any pointers on how to do this?

Jason

2 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 22 Oct 2013, 07:27 AM
Hello Jason,

You can get reference to the Grid dataSource field use the group API to group the widget. There is also an API for showing/hiding given grid column.

Regards,
Nikolay Rusev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Jason
Top achievements
Rank 1
answered on 22 Oct 2013, 04:11 PM
Excellent, thanks for the help with that.  Here is what I came up with and it seems to work perfectly!

$('#ButtonID').click(function() {
     var grid = $('#GridID').data('kendoGrid');
     grid.showColumn('FirstName');
     grid.showColumn('LastName');
     grid.hideColumn('AccountNumber');
     grid.dataSource.group([{field: "City"}]);
});
Tags
Grid
Asked by
Jason
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Jason
Top achievements
Rank 1
Share this question
or