How do I avoid repeated ajax calls when sharing data source between 2 Kendo grids

2 posts, 0 answers
  1. littleGreenDude
    littleGreenDude avatar
    17 posts
    Member since:
    Jan 2014

    Posted 28 Apr 2014 Link to this post

    I have 2 kendo grids that use the same data source. One displays zero
    balance orders and the other displays orders with balances > 0. Each
    one makes the same ajax call to get the full list of data and then
    applies a filter for the grid (0, >0). Is there a way to have both
    grids use the same datasource, but only make the ajax call once?
  2. littleGreenDude
    littleGreenDude avatar
    17 posts
    Member since:
    Jan 2014

    Posted 28 Apr 2014 Link to this post

    More info...

    @(Html.Kendo().Grid<CustomerOrder>()
        .Name("Orders")
        .Events(events => events.DataBound("onDataBound"))
        .DataSource(dataSource => dataSource  
            .Ajax()
            .ServerOperation(false)
            .Read(read => read.Action("OrderListAjax", controller))
            .PageSize(Constants.PageSize)
            .Filter(filters => { filters.Add(c => c.CurrentOrderBalance).IsGreaterThan(0); })
            )


     

    @(Html.Kendo().Grid<CustomerOrder>()
        .Name("ZeroBalanceOrders")
            .Events(events => events.DataBound("onZBdataBound"))
        .DataSource(dataSource => dataSource  
            .Ajax()
            .ServerOperation(false)
            .Read(read => read.Action("OrderListAjax", controller))
            .PageSize(Constants.PageSize)
            .Filter(filters => { filters.Add(c => c.CurrentOrderBalance).IsEqualTo(0); })
            )
        .AutoBind(false)

     

    Both grids make the same call to OrderListAjax and then filter. I would
    like to make the call once to retrieve the data and then apply the
    filter for each grid.
Back to Top