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

Auto binding columns from datasource, and adding formatting

1 Answer 272 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 1
Roger asked on 02 Mar 2016, 06:37 PM

Hello!

With a kendo grid, if you don't specify the columns it will automatically bind everything in the datasource without any kind of formatting etc.

I have a situation where I desire this behavior (I have a variable datasource, with different columns for different situations) but I would like to be able to specify certain properties, like width, hidden:true/false etc.

Is it possible to specify column properties while still auto-binding from the datasource, and not defining which fields go to which column?

This would be very useful.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 04 Mar 2016, 06:37 AM
Hello Roger,

Yes, indeed if you do not define columns property for the Kendo UI Grid it will use all the fields from the data source and auto generate the columns. Any customization should be set in the columns section, but you do not know the columns beforehand and thus they are not declared initially.

You can try to retrieve and get the columns configuration using ajax request before the grid initialization. Add each field to the columns array and pass that array to the columns configuration in the grid initialization code. Please refer to the http://dojo.telerik.com/AfAqe example for a reference. The columns array is created based on some data and then pass to the columns property in the grid configuration.

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