简体   繁体   中英

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
        }

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()
                    }
                }
            }
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM