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

Kendo Grid Server Side Paging With Model Binding

5 Answers 322 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Janith
Top achievements
Rank 1
Janith asked on 11 Jun 2014, 05:29 AM
Hi I have a kendo grid in my partial view.
And I have bind a model as the grid data source. And mention that my grid don't have a Read method. Instead of read method I have use the model.
Here is my view..
@model Project.MVC.Areas.Razor.Models.CustomerListModel

<div id="dvResultGrid">
@(Html.Kendo().Grid<Portal.Application.BoundedContext.ScreenPop.Dtos.Customer>(Model.CustomerList)
.Name("grdWindowResults")

.Columns(columns =>
{
columns.Bound(x => x.Name1).Visible(true);
columns.Bound(x => x.Name2).Visible(true);
columns.Bound(x => x.ContactName);
columns.Bound(x => x.BillingAddress1);
})
.Pageable()
.Sortable(x => x.Enabled(false))
.Scrollable(x => x.Height("auto"))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.Reorderable(reorder => reorder.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.PageSize(5)
.Model(model =>
{
model.Id(p => p.CustomerId);

})
)
)
</div>
And what I have to do is, I need to do server-side paging for my grid. How can I do that with out a read method. Is there any option?




5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 11 Jun 2014, 07:54 AM
Hello Janith,

If you want to do server paging you have to remove the Ajax configuration of your data source. The rest should be done automatically.

@(Html.Kendo().Grid<Portal.Application.BoundedContext.ScreenPop.Dtos.Customer>(Model.CustomerList)
.Name("grdWindowResults")

.Columns(columns =>
{
columns.Bound(x => x.Name1).Visible(true);
columns.Bound(x => x.Name2).Visible(true);
columns.Bound(x => x.ContactName);
columns.Bound(x => x.BillingAddress1);
})
.Pageable()
.Sortable(x => x.Enabled(false))
.Scrollable(x => x.Height("auto"))
.Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
.Reorderable(reorder => reorder.Columns(true))
.DataSource(dataSource => dataSource
.Server()
.PageSize(5)
.Model(model =>
{
      model.Id(p => p.CustomerId);
})
)
)


Regards,
Atanas Korchev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Janith
Top achievements
Rank 1
answered on 11 Jun 2014, 08:22 AM
I have removed the Ajax configuration, Then the grid is not working ( data is not loading)
0
Atanas Korchev
Telerik team
answered on 11 Jun 2014, 08:25 AM
Hi,

Can you confirm that your model is not empty? The grid should render initially using the specified model. If the model is empty then the grid will be empty too.

I recommend checking the server binding demo from the sample ASP.NET MVC application for a working example.

Regards,
Atanas Korchev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Janith
Top achievements
Rank 1
answered on 11 Jun 2014, 09:15 AM
Yeah,thanks It' s working. But the problem is I have written a javascript function to display data related to the selected row  of the grid.
So that function not working because of the Ajax configurations off.
0
Atanas Korchev
Telerik team
answered on 11 Jun 2014, 01:25 PM
Hello,

If you need both the JavaScript events to fire and server paging you have to use Ajax binding with a configured Read method. Otherwise you should pick between client-side paging (your initial configuration) or implementing custom selection code via jQuery.

Regards,
Atanas Korchev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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