Jqgrid, фильтрующий панель инструментов, не может создать свойство 'filters' on string '' при поиске - PullRequest
0 голосов
/ 18 марта 2020

Я пытаюсь отфильтровать результаты в столбце jqgrid для электронной почты. Ниже мой код. Когда я пытаюсь отфильтровать, я получаю ошибку, как описано ниже, через снимок экрана

$(document).ready(function(){
    var homeGrid=$('#homeGrid');
    homeGrid.jqGrid({
        url:'/SpringBootData/departmentEmployees',
        mtype:'GET',
        colNames:['DeparmentId','DepartmentName','EmployeeId','EmployeeName','EmployeeMail'
            ,'EmployeeGender','EmployeeDoj','EmployeeType'],
        colModel:[{name:'deptId',index:'deptId',hidden:true,editable:true},
            {name:'deptName',index:'deptName',editable:true},
            {name:'empId',index:'empId',hidden:true,editable:true,},
            {name:'empName',index:'empName',editable:true,edittype:'text',search: true},
            {name:'empMail',index:'empMail',editable:true,editrules:{email:true,required:true},
                search: true,stype:'text',searchoptions: { sopt: ["cn"]}},
            {name:'empGender',index:'empGender',editable:true,edittype:'select',
                editoptions: {value:{'m':'Male','f':'Female'}},formatter:'select',search: true,stype:'select'},
            {name:'empDoj',index:'empDoj',editable:true,edittype:'text'},
            {name:'employeeType',index:'employeeType',editable:true,edittype:'select',
                editoptions: {value:{1:'Permanent',2:'Contractor'}},formatter:'select'}
            ],
        datatype:'json',
        loadonce: true,
        gridview:true,
        height:'auto',
        rownumbers:true,
        rowList:[5,10,20],
        rowNum:10,
        sortable:true,
        sortorder:'asc',
        search:true,
        sortname:'empName',
        postData:"",
        jsonReader: {
            repeatitems: false,
            id: "empId",
            root: function (obj) { return obj; },
            page: function (obj) { return 1; },
            total: function (obj) { return 1; },
            records: function (obj) { return obj.length; }
        },
        pager : '#navGrid',
        toolbar:[true,'bottom'],
        serializeGridData:function(postData){
            return JSON.stringify(postData);
        },
        gridComplete:function(){
            $(this).find('tr').find('td[aria-describedby="homeGrid_empDoj"]').each(function(index,obj){
                $(this).datepicker({ dateFormat: 'yyyy-mm-dd' });
            })
        },
        onSelectRow:function(rowId){
            //console.log(this);
        }
    }).navGrid('#navGrid',{closeOnEscape:true,del:false,add:false,edit:true,search:true,
        edittext:'EditRow',edittitle:'Edit'},{closeOnEscape:true,
            navkeys:[true,38,40],
            mtype:'PUT',
            ajaxEditOptions: { contentType: 'application/json; charset=utf-8', dataType: 'json' },
            url:'/SpringBootData/update',
            width:'auto',
            height:'auto',
            closeAfterEdit: true,
            serializeEditData:function(postData){
                return JSON.stringify(postData);
                },
            beforeShowForm:function(formId){
            $(formId[0]).find('input[name="empDoj"]').datepicker({ dateFormat: 'yy-mm-dd',changeMonth: true, changeYear: true, yearRange: '1989:2020' });
            },
            beforeSubmit:function(postData){
                console.log(postData);
                return[true ,"sending to updated"];
            },
            afterSubmit:function(response,postData){
                if(response.responseJSON.deptId>0){
                homeGrid.jqGrid('setGridParam',{datatype:'json'}).trigger("reloadGrid");
                }
            }
                },{},{},{multipleSearch : true},{});
    homeGrid.jqGrid('filterToolbar',{searchOnEnter:false});

})

Ниже приведен снимок экрана

enter image description here

Я получаю сообщение об ошибке в файле jqgrid.sr c, как показано ниже

enter image description here

Может кто-нибудь, пожалуйста, помогите мне в этом. Я не могу сделать фильтрацию по столбцам

1 Ответ

0 голосов
/ 20 марта 2020

Вместо того, чтобы мы поддерживали коммерческий Guriddo jqGrid , ваша проблема может заключаться в том, что параметр postData не может быть строкой. Это должен быть объект.

Для того, чтобы это работало, вам может понадобиться либо прокомментировать postData: "" в параметрах сетки, либо установить для него такой объект

homeGrid.jqGrid({
    ...
    postData:{},
    ...
});
...