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

[Solved] dynamic columns and server paging/sorting/filtering

5 Answers 848 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 22 May 2014, 08:13 PM
I followed this post for generating a grid with dynamic columns:

http://jsbin.com/cefuduju/1/edit

This does not show how to implement server-side paging/sorting/filtering.

According to this post:

http://www.telerik.com/forums/binding-kendoui-grid-to-dynamic-column-and-values-kendo-ui-complete-resources-buy-try

It says in order to do this on the server side you need to configure the transport read method of the dataSource.

How am I supposed to create the dataSource using an ajax call and setup the read method so server-side actions will work?

5 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 26 May 2014, 10:56 AM
Hi Justin,

I already answered to this query in duplicated support ticket created by you - #822616. Please keep in mind that it is highly recommended that you keep related questions in one support thread or a forum post, so that we can easily keep track of your support history and provide better answers in a shorter time.

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ryan
Top achievements
Rank 1
answered on 26 Nov 2014, 05:32 AM
Is there any chance you could post the solution to the forums? I have the same problem. I want to bind to a remote data source with server-side pagination. The linked sample doesn't show this, and I've not found a clear answer in the docs as to whether the columns could be retrieved from the server response. Should the client retrieve column data as a second API call, or is it possible to retrieve the columns from the response and use that in the grid options?

Thanks,
Ryan Riley
0
Vladimir Iliev
Telerik team
answered on 26 Nov 2014, 08:04 AM
Hello Ryan,


Please check the answer of the ticket below:


Currently we have no such example which we can provide, however as a general direction (if you need to enable CRUD operations over the data) you should get at least one record from the server (for example using jQuery ajax method) which to use for generating the grid columns and dataSource schema. Please check the required changes below:

1) Get one item from the server using jQuery ajax method - this item will be used to generate the columns and dataSource schema.

2) Pass the received model from the above point to "generateModel" function. Do not apply date format in the dataSource "schema.model" definition or the "parse" function - the correct place for applying the format is the grid columns definition.

3) Generate the columns of the Grid the same way as you generate the model. If given field is "Date" type add the "format" option to the current column.

Also in order to send the sorting / filtering parameters correctly serialized to the MVC Controller you should apply the following points:

1) Include the "kendo.aspnetmvc.min.js" script to the page.

2) Set the grid dataSource "type" option to "aspnetmvc-ajax"


Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ryan
Top achievements
Rank 1
answered on 26 Nov 2014, 05:26 PM
Thank you, Vladimir. To confirm, if I want to leverage the dataSource.transport, I do need to send at minimum two requests to the server: one I submit to retrieve the column information and a the rest handled by the dataSource. Is that accurate?
0
Vladimir Iliev
Telerik team
answered on 27 Nov 2014, 10:29 AM
Hi Ryan,

Yes, this is the idea behind current approach.

Regards,
Vladimir Iliev
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
Justin
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or