Auto binding columns from datasource, and adding formatting

2 posts, 0 answers
  1. Roger
    Roger avatar
    1 posts
    Member since:
    Feb 2014

    Posted 02 Mar 2016 Link to this post


    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.


  2. Eyup
    Eyup avatar
    4081 posts

    Posted 04 Mar 2016 Link to this post

    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 example for a reference. The columns array is created based on some data and then pass to the columns property in the grid configuration.

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top