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

Paging Problems with Grid

1 Answer 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gil
Top achievements
Rank 1
Gil asked on 20 Jun 2014, 01:38 PM
I've been having several problems the last few days when it comes to paging data from a grid.  I have a webform that when the user submits goes to the controller where I am calling a stored procedure from a database and passing it 2 parameters.  The stored proc then returns several columns and hundreds of rows back.  This is then passed into a LINQ in my controller that parses out the information based on certain attributes the user selected.  I then pass this information into a view.  When the view is released I am getting a full grid with all the information along with pages to tab through.  That's where the issue is.  The minute I click on a page it refreshes the page and now the grid has no information whatsoever on it. Here is the code:

Controller:
        public ActionResult Results( All the webform parameters are being passed in here )
​            var model = db.StoredProcedure(startDate, endDate)
    //LINQ query is here
                        .Take(1000)
                        .Select(r => new LINQS
                        {
//Selects the data that I want
                        });

            return View("Results", model.ToList());


View:

//A bunch of non relatable html
@(Html.Kendo().Grid(Model)
    .Name("Grid")
    .Pageable()
    .Scrollable()
    .Filterable()
    .Groupable()
    )



1 Answer, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 24 Jun 2014, 10:12 AM
Hello Gil,

I assume you are looking for a way to perform the paging on the client side. You can do this only if you have configured the DataSource to be ajax and the ServerOperation option to be false. Please notice that you can still initially bind the items to the Grid without doing an Ajax call at all.

Here is a small example:

View:
 
@model IEnumerable<KendoMVCWrappers.Models.Person>
 
@(Html.Kendo().Grid<KendoMVCWrappers.Models.Person>(Model).Name("people")
    .DataSource(dataSource => dataSource
        .Ajax()
        .ServerOperation(false)
        .PageSize(3)
        .Model(model=>model.Id(m=>m.PersonID))           
            .Update(up=>up.Action("UpdatePerson","Home"))
    )           
    .Columns(columns =>
    {
        columns.Bound(c => c.PersonID);
        columns.Bound(c => c.Name);
        columns.Bound(c => c.BirthDate).Format("{0:dd/MM/yyyy}");
        columns.Command(cmd => cmd.Edit());
    })           
    .Pageable()
    .Sortable()
)
 
 
Controller:
        public ActionResult Index()
        {
            ViewBag.Message = "Modify this template to kick-start your ASP.NET MVC application.";
 
            return View(people); //people is IEnumerable<Person>
        }

I hope this is what you are searching for.

Kind Regards,
Petur Subev
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
Gil
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or