【问题标题】:jqgrid load from database does not work filterToolbar从数据库加载 jqgrid 不起作用 filterToolbar
【发布时间】:2013-04-05 15:56:33
【问题描述】:

我正在使用 Asp.net MVC4、jqgrid 4.4.4 和 jquery 1.9 jqGrid 从查询加载到数据库,但我无法过滤字段,当我输入一个值时不搜索,它显示相同的值,但是当我在 jqgrid 中定义值时 loadonce: true 仅在第一个搜索页面,我该如何解决这个问题?我应该在哪里修改代码?

这是我的代码,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}]);

【问题讨论】:

  • 如果你想使用loadonce: true控制器动作@Url.Action("DatosBuscaPersona", "raTabPersonaReclamante")必须返回所有数据(而不是一页数据)刚刚排序对应于sidx和@ 987654325@。或者,您必须实现 服务器端过滤(参见 Mark 的答案)

标签: asp.net-mvc jquery-ui asp.net-mvc-4 jqgrid jqgrid-asp.net


【解决方案1】:

默认情况下,过滤将由您的控制器处理,您将看到这些值在_searchfilters 中传递给控制器​​。

loadonce: true 在第一页上工作的原因是它在客户端进行过滤。

我建议在下面的链接中查看 Oleg 关于过滤的答案,这让我能够为我的应用程序进行服务器端过滤。

ASP.NET MVC 2.0 Implementation of searching in jqgrid

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-12
    • 2014-10-13
    • 1970-01-01
    • 2015-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-20
    相关资源
    最近更新 更多