سؤال

I'm working with Asp.net MVC4, jqgrid 4.4.4 and jquery 1.9 The jqGrid is loaded from a query to the database, but I can not filter the fields, when I put a value doesn't search, it shows me the same values, but when I define in jqgrid the value loadonce: true only in the first search page, How I can resolve this problem? Where I should be modify the code?

This is my code, 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}]);
هل كانت مفيدة؟

المحلول

By default the filtering will be handled by your Controller, and you will see these values being passed to the controller in the _search and filters.

The reason the loadonce: true is working on the first page is that it is doing the filtering on the client side.

I would suggest checking out Oleg's answer on filtering at the link below, it is what put me on the track to do server side filtering for my application.

ASP.NET MVC 2.0 Implementation of searching in jqgrid

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top