2015-05-19 2 views
0

Привет я следующий кодDataTables пагинация не работает

JQuery DataTables плагин (VIEW)

<script type="text/javascript"> 
    $(document).ready(function() { 
     $('#table1').DataTable({ 

      /* PROCESS NOTIFICATION */ 
      "processing": true, 

      /* SERVER SIDE PROCESSING */ 
      "serverSide": true, 
      "ajax": 
      { 
       "url": "GetNonstandardProgram", 
       "type": "POST" 
      }, 


      "columnDefs": 
      [ 
       /* HIDE ID COLUMN */ 
       { 
        "targets": [ 0 ], 
        "visible": false, 
        "searchable": false 
       }, 

       /* ACTION COLUMN */ 
       { 
        "aTargets": [-1], 
        "mData": null, 
        "mRender": function (data, type, full) { 
         return '<a href="#" onclick="alert(\'' + full[0] + '\');">test</a>'; 
        } 
       } 
      ], 

      "bSort":false, 
      "bPaginate":true, 
      "iDisplayStart": 5, 
      "iDisplayLength": 2 

     }); 
    }); 

класса для параметров, которые я скачал (модель)

/// <summary> 
    /// Class that encapsulates most common parameters sent by DataTables plugin 
    /// </summary> 
    public class jQueryDataTableParamModel 
    { 
     /// <summary> 
     /// Request sequence number sent by DataTable, 
     /// same value must be returned in response 
     /// </summary>  
     public string sEcho { get; set; } 

     /// <summary> 
     /// Text used for filtering 
     /// </summary> 
     public string sSearch { get; set; } 

     /// <summary> 
     /// Number of records that should be shown in table 
     /// </summary> 
     public int iDisplayLength { get; set; } 

     /// <summary> 
     /// First record that should be shown(used for paging) 
     /// </summary> 
     public int iDisplayStart { get; set; } 

     /// <summary> 
     /// Number of columns in table 
     /// </summary> 
     public int iColumns { get; set; } 

     /// <summary> 
     /// Number of columns that are used in sorting 
     /// </summary> 
     public int iSortingCols { get; set; } 

     /// <summary> 
     /// Comma separated list of column names 
     /// </summary> 
     public string sColumns { get; set; } 
    } 

метод, который обжигали от jQuery (CONTROLLER)

public JsonResult GetNonstandardProgram(SWIN.Models.jQueryDataTableParamModel param) 
     { 

, но на этом этапе проблема.

enter image description here

все значения равны нулю или нулевой. Итак, вопрос в том, почему я не вижу значения параметров?!

В DataTables посылает эти параметры с помощью POST

... 
&start=5 
&length=2 
&search[value]= 
... 
&search[regex]=false 

Спасибо

+0

вы можете попробовать использовать ' "iDisplayLength": 2' и другие свойства перед «serverSide»: true' и дайте мне знать. cheers –

+0

привет, к сожалению это не поможет, но хорошая идея. Имя параметра необязательно или оно должно быть названо iDisplayLength? Спасибо – Muflix

ответ

0

я понял это. я изменил название параметров в классе

public class jQueryDataTableParamModel 
    { 

к этому

/// <summary> 
/// Number of records that should be shown in table 
/// </summary> 
public int length { get; set; } 
//public int iDisplayLength { get; set; } 

/// <summary> 
/// First record that should be shown(used for paging) 
/// </summary> 
public int start { get; set; } 
//public int iDisplayStart { get; set; } 

и просто использовали param.start и param.length

Смежные вопросы