Omar Seleim
Omar Seleim

Reputation: 185

Kendo grid with server side with parameters

I have kendo grid server side pagination and filtering based on start date and end date (2 Filters ), in first time grid drawn based on the 2 filters correctly . When the 2 filters changed the grid draw correctly then when I go to another page the filters values sent to action server (action update data source) sent as firstly call not send current values . Data source code is

dataSource: {
            type: "aspnetmvc-ajax",
            transport: {
                read: {
                    url: "@Html.Raw(Url.Action("GetAllOldExcuse", "Security"))",
                    data: {
                        startDate: $('#FromDate').val(), endDate: $('#FromTo').val()
                    }
                }
            },
            schema: {
                model: {
                    fields: {
                        ID: { type: "number" },

                    }
                }
                , data: "Data",
                total: "Total",
                errors: "Errors",
                AggregateResults: "AggregateResults",
            },
            pageSize: 10,
            serverPaging: true,
            serverSorting: true,
            serverFiltering: true,
            serverGrouping: true,
            serverAggregates: true
        }

Upvotes: 0

Views: 902

Answers (1)

Joe Glover
Joe Glover

Reputation: 1026

Omar, you should change your data property into a function, so that it get re-evaluated each time the datasource requests data:

        transport: {
            read: {
                url: "@Html.Raw(Url.Action("GetAllOldExcuse", "Security"))",
                data: function() {
                    return {
                        startDate: $('#FromDate').val(),
                        endDate: $('#FromTo').val()
                    }
                }
            }
        }

Upvotes: 1

Related Questions