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

Grid sorting in Ajax-loaded partial views

4 Answers 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 26 Jul 2012, 08:34 AM
Guys,

I seem to have boxed myself into a corner and hope someone can help.  

I am working on a new MVC 3 front end to an existing large app, which previously used a Windows Forms front end.  I have made some progress using Syncfusion controls, but find them a bit flaky, so and trying out the MVC wrapper for Kendo.

The app uses a hash-based URL scheme like GMail, so that it loads panels inside the main frame for a smoother and faster experience.  The panels include grids, tabs etc.  using partial views.  The rendering is server side.

My problem is that the Kendo grid  with MVC wrappers (server-bound to iEnumerable lists)  seems to want do a whole page GET to sort a column, which breaks my scheme, since it just loads the page without the main frame.  I thought maybe I could use the Ajax mode, but this wants to serial all of my object properties - which is large and rambling and not something I want to reinvent to fit into a view - in fact it throws a circular reference error, which is quite believable.

Any ideas?  Is my planned doomed?

Mark

4 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 26 Jul 2012, 10:11 AM
Hi Mark,

 You need to use Ajax binding mode for your scenario. To serialize fewer fields you could use a view model:

var result = data.Select( o =>
{
  Property1 = o.Property1,
  Property2 = o.Property2
});
 
return Json(result.ToDataSourceResult(request));


I hope this helps,

Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mark
Top achievements
Rank 1
answered on 26 Jul 2012, 01:47 PM
Atanas.
That sounds great, and a very prompt reply indeed!

I appreciate this next question is a bit out of scope of Kendo UI, but since my model objects don't currently support iQueryable, is there as concise a way of create the ViewModel objects using an IEnumerable? 

Cheers
Mark
0
Atanas Korchev
Telerik team
answered on 26 Jul 2012, 02:00 PM
Hi Mark,

 The Select extension method is available for IEnumerable<T> as well. Your data is probably contained in a list or array.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mark
Top achievements
Rank 1
answered on 26 Jul 2012, 02:29 PM
I never realised that!  You're right...

Apologies
Mark
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Mark
Top achievements
Rank 1
Share this question
or