2013-04-05 60 views
0

我正在使用Asp.net MVC4,jqgrid 4.4.4和jquery 1.9 jqGrid從查詢加載到數據庫,但我無法過濾字段,當我把一個值不搜索,它顯示我相同的值,但是當我在jqgrid中定義的值loadonce:true只在第一個搜索頁面中,我該如何解決這個問題?我應該在哪裏修改代碼?jqgrid從數據庫加載不起作用filterToolbar

這是我的代碼,jqGrid的:

jQuery(document).ready(function() { 
     jQuery("#tbBuscaRec").jqGrid({ 
      url: '@Url.Action("DatosBuscaPersona", "raTabPersonaReclamante")', 
      datatype: 'json', 
      mtype: 'POST',  
      postData: { Parametro: Param }, 
      colNames: ['Id', 'IdPer', 'Doc', 'CI/NIT', 'Nombres', 'Apellido Paterno', 'Apellido Materno', 'Apellido Esposo'], 
      colModel: 
      [ 
       { name: 'ip_idpersona', index: 'ip_idpersona', formatter: 'number', hidden: true }, 
       { name: 'ip_idpersonadoc', index: 'ip_idpersonadoc', formatter: 'text', hidden: true }, 
       { name: 'ip_partipodoc', index: 'ip_partipodoc', align: 'left', width: '4', editable: true, edittype: 'text', editoptions: { readonly: true }, search: false }, 
       { name: 'ip_nrodoc', index: 'ip_nrodoc', sortable: true, align: 'left', width: '8', editable: true, edittype: 'text', editoptions: { readonly: true} }, 
       { name: 'ip_nombres', index: 'ip_nombres', sortable: true, align: 'left', width: '15', editable: true, edittype: 'text', editoptions: { readonly: true} }, 
       { name: 'ip_appaterno', index: 'ip_appaterno', sortable: true, align: 'left', width: '15', editable: true, edittype: 'text', editoptions: { readonly: true } }, 
       { name: 'ip_apmaterno', index: 'ip_apmaterno', sortable: true, align: 'left', width: '15', editable: true, edittype: 'text', editoptions: { readonly: true} }, 
       { name: 'ip_apesposo', index: 'ip_apesposo', sortable: false, align: 'left', width: '15', editable: true, edittype: 'text', editoptions: { readonly: true} } 
      ], 
      pager: '#pg_tbBuscaRec', 
      rowNum: 100, 
      rowList: [100, 200, 300], 
      sortname: 'ip_nombres', 
      sortorder: 'asc', 
      rownumbers: true, 
      multiselect: false, 
      gridview: true, 
      height: 180, 
      width: 490, 
      ignoreCase: true, 
//   loadonce: true, 
     }); 
    }); 
    jQuery("#tbBuscaRec").jqGrid('navGrid', '#pg_tbBuscaRec', { view: false, edit: false, add: false, del: false }, {}, {}, {}, { multipleSearch: true, closeAfterSearch: true, closeOnEscape: true }); 
    jQuery("#tbBuscaRec").jqGrid('filterToolbar'); 
    jQuery("#tbBuscaRec").trigger("reloadGrid", [{ current: true}]); 
+0

如果你想用'loadonce:TRUE'控制器動作'@ Url.Action( 「DatosBuscaPersona」, 「raTabPersonaReclamante」)'必須返回所有數據**(**的,而不是一個頁面數據),只是按照「sidx」和「sord」排序。或者,您必須實現**服務器端過濾**(請參閱標記的答案) – Oleg 2013-04-06 14:13:14

回答

1

默認情況下,篩選會被你的控制器處理,你會看到被傳遞到了_searchfilters控制器來使用這些值。

loadonce: true在第一頁上工作的原因是它在客戶端執行過濾。

我建議在下面的鏈接上檢查Oleg的過濾答案,這是什麼讓我在軌道上做我的應用程序的服務器端過濾。

ASP.NET MVC 2.0 Implementation of searching in jqgrid