Model binding new Datatables 1.10 parameters

前端 未结 6 1515
南方客
南方客 2021-02-01 16:44

In Datatables 1.10 the ajax server side parameters changed from

public class DataTableParamModel
{ 
    public string sEcho{ get; set; }
    public string sSearc         


        
6条回答
  •  没有蜡笔的小新
    2021-02-01 17:48

    I ran into the same issue when moving to 1.10. Basically, I changed my parameter class like this (getting rid of the unsupported parameters):

    public class jQueryDataTableParamModel
    {
        /// 
        /// Request sequence number sent by DataTable,
        /// same value must be returned in response
        ///        
        public string draw { get; set; }
    
        /// 
        /// Number of records that should be shown in table
        /// 
        public int length { get; set; }
    
        /// 
        /// First record that should be shown(used for paging)
        /// 
        public int start { get; set; }
    }
    

    In my controller, I get the search value, sort order, and sort column like this:

            var searchString = Request["search[value]"];
            var sortColumnIndex = Convert.ToInt32(Request["order[0][column]"]);
            var sortDirection = Request["order[0][dir]"]; // asc or desc
    

提交回复
热议问题