1

I am working kendo Grid , that grid will consist large data.

I need to refresh the grid data on button click events and on dropdown change events it is working fine by reading data of the grid on clicks and dropdown change events.But the grid data is reloading even there is no change in it that means the data is same as previous data of grid.so it is causing performance issues to me.

How can I know whether grid data is changed or not?

Nic
  • 12,220
  • 20
  • 77
  • 105
Arjun
  • 2,159
  • 1
  • 17
  • 26

2 Answers2

0

You mention the issue is performance, and the function you ask is comparing your large data if its has a change in it. Then comparing large data in client with the data on db will also makes no change with performance, IMO it will make it slower. So consider using server-side operation e.g pagination.

Yet regarding to your question, I will add some links that helps you do some compare logic:

MSDN - Enumerable.SequenceEqual

Stackoverflow - Is there a built-in method to compare collections in C#?

Solution: request only data that related on current page to server, do comparison if its not equal then send the data back to client(browser).

Community
  • 1
  • 1
Dion Dirza
  • 2,575
  • 2
  • 17
  • 21
0

You can't do what you want. However, if you properly implement pagination your grid will only retrieve the current page, which shouldn't be much.

This is easy if you use an ORM like Entity Framework, since ToDataSourceResult will change the query to include the paging, sorting and filtering options.

Something like this:

Controller

public ActionResult GetGridData([DataSourceRequest]DataSourceRequest request)
{
    using (var context = new EntityFrameworkContext()) 
    {
        IQueryable<MyModel> result = context.Products.Where(w => w.Something).Select(s => new MyModel());
        return Json(result.ToDataSourceResult(request));
    }
}

View

@(Html.Kendo().Grid<MyModel>()
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.Name);
        columns.Bound(c => c.Date);
    })
    .Pageable(pageable => pageable
        .Refresh(true)
        .PageSizes(true)
        .ButtonCount(10)
        .PageSizes(new[] { 20, 50, 100 }))
    .DataSource(ds => ds
        .Ajax()
        .Read(r => r.Action("GetGridData", "Home"))
        .PageSize(20)
    )
)
Nic
  • 12,220
  • 20
  • 77
  • 105