【问题标题】:Jqgrid toolbar filtering giving Cannot create property 'filters' on string '' when trying to searchJqgrid 工具栏过滤在尝试搜索时无法在字符串“”上创建属性“过滤器”
【发布时间】:2020-03-18 05:02:44
【问题描述】:

我正在尝试在 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});

})

下面是截图

我在 jqgrid.src 文件中遇到错误,如下所示

有人可以帮我解决这个问题吗?我无法对列进行过滤

【问题讨论】:

  • 我看到你在使用 free-jqGrid,希望 Oleg 能回答你。我看到您同时使用工具栏搜索和对话搜索。您可以尝试禁用对话搜索并查看工具栏搜索是否有效,反之亦然。
  • @TonyTomov 即使在禁用搜索对话框后我也收到错误消息。你能告诉使用哪个 jgrid 代替 free-jqgrid 可以解决问题吗
  • @Oleg 你能评论一下吗?

标签: jquery jqgrid toolbar


【解决方案1】:

相反,我们支持商业Guriddo jqGrid 您的问题可能是因为 postData 参数不能是字符串。应该是对象。

为了使其正常工作,您可能需要在网格选项中评论 postData : "" 或将其设置为这样的对象

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

【讨论】:

  • 当我保留 postData:{} 然后 thr 请求 URL 就像下面给出的我不想要并给我一个错误 localhost:8081/SpringBootData/departmentEmployees?{%22_search%22:true,%22nd%22: 1584701030210,%22rows%22:10,%22page%22:1,%22sidx%22:%22empName%22,%22sord%22:%22asc%22}
  • 能否请您提供 Gurrido Jqgird js,因为我公司的互联网限制政策导致我无法下载 谢谢!!
  • 对不起,如果你有限制,我无法克服它。您可以在家中下载 Guriddo。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-29
  • 2015-04-28
  • 2016-05-18
  • 2011-08-14
  • 1970-01-01
  • 2015-05-29
相关资源
最近更新 更多