2013-04-05 63 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