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

Populate columns dynamically

5 Answers 283 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 14 Jun 2012, 05:40 PM
So I've been working a lot with the Kendo Grid lately. I've been able to get Server side filtering, sorting and virtual paging working in MVC. Now that I've found that out I want to be able to update the columns of the grid when I'm filtering data.

For example I have a grid which will list a set of people. I have the ability to filter those people by sub sets such as workers, farmers, or managers. Each of these filters would cause me to want to display different column information which is more pertinent to the subset I'm filtered on.

I've tried a few things:

1. Breaking the parameter for a grid's columns out into a separate variable (similar to how you would with a data source). This will work when the page loads, but my postback with the filters will not refresh the column list in the grid.
2. I've tried making a function that will look at what changed and pass a new array of columns, that doesn't work either
3. I've tried calling $("#MyGrid").empty(); and then re-building the object. This works about 1 of 3 times or less...I'm not quite sure what occurs as I'm getting errors from the minified web ui javascript. The errors I've gotten are:
     - d.dataSource.group() is undefined
     - f is not a function

I'm looking for any way in which I can refresh the column list with new data. Or a way in which I can display this information without making multiple grids which I would have to then show or hide.

EDIT: I want it to be known that I'm not trying to show/hide columns (as I know that is currently in feature request) but I'm looking instead to refresh the column collection used on the current grid.

5 Answers, 1 is accepted

Sort by
0
Brian
Top achievements
Rank 1
answered on 15 Jun 2012, 12:35 PM
One other thing I've seen posted in the forums a lot was the use of templates.

Would it instead be possible to switch out templates when my filter changes and have it update the columns? I'm guessing this wouldn't work, but I'm just about fresh out of ideas...

I had some time to make a jsfiddle of the situation. I tried to keep the code as clean as possible. Hopefully the scenario is understandable. I basically click a button that will only get farmers, but the farmers have an extra column that doesn't apply to the others. So when filtering on only farmers I want to be able to display that column
JSFiddle

I have tried the grid method refresh() and that does not seem to have the desired result. Perhaps the grid refreshes but not the columns...
0
Brian
Top achievements
Rank 1
answered on 18 Jun 2012, 12:58 PM
So I saw this thread and I'm assuming that what I'm trying to do must not be currently supported. This does raise concern about when the projected release date for the Q2 release is (ie end of Q2, or mid) or if there is a way to access the beta in the mean time. This functionality is unfortunately of pretty high importance for my site, unless another way to do things can be recommended I've done everything I can think of to get these grids working in my desired fashion.

Is there any way I can blow away the grid entirely and re-populate it causing the columns to update? I have not been able to successfully do this.
0
Alexander Valchev
Telerik team
answered on 19 Jun 2012, 08:00 AM
Hi Brian,

You are right, the dynamic change of grid columns is not supported at present. The Beta of Q2 release is scheduled for this week and you should be able to download and test it very soon. Unfortunately the functionality that you are looking for is not planned for this release, but if you are interested in what is coming next you may take a look at the official roadmap.

Regarding to your second question, the grid currently does not expose destroy methods, however the implementation of such functionality has been discussed and we will consider its implementation for one of our future releases. Actually this idea has been already submitted at KendoUI user voice forum, so if you wish you may cast a vote for it or leave a comment. The more votes it collect, the higher priority it will have.

Greetings,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Brian
Top achievements
Rank 1
answered on 19 Jun 2012, 12:04 PM
Hi Alexander,

Thanks for responding. So, the dynamic column updating does not occur, and is not planned for Q2, is the destroy functionality you refer to going to be present in Q2 beta, or is it planned for a later release as well?

Thanks,
Brian
0
Alexander Valchev
Telerik team
answered on 19 Jun 2012, 02:07 PM
Hello Brian,

As I said in my previous reply the implementation of destroy functionality has been discussed, but I am afraid that at this stage it is not in our immediate plans. I cannot tell when this grid improvement will be available, but I can inform you that it is not scheduled for the next official release and will not be presented in the beta release.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Brian
Top achievements
Rank 1
Answers by
Brian
Top achievements
Rank 1
Alexander Valchev
Telerik team
Share this question
or