【问题标题】:jqGrid toobar not filtering when typing键入时 jqGrid 工具栏未过滤
【发布时间】:2020-10-06 22:28:24
【问题描述】:

使用 jqGrid js v5.5.0,键入时过滤功能不适用于某些字段。

在“标题”字段中键入会导致该列仅显示与输入内容匹配的值。

在串行过滤器中键入“2”不会显示任何内容。

预期结果是串行列的行为与标题列完全相同并显示部分匹配。

所有数据都预加载到网格中。

这是演示问题的代码和小提琴。

http://jsfiddle.net/rboarman/p7uyq6w2/15/

var mydata = [{
    "Id": "5b1600409fc4a04a1001af6c",
    "HitNumber": "2169957",
    "Title": "Centrifuge",
    "ClientIdNumber": "",
    "Status": "Requested",
    "IsVisible": false,
    "Manufacturer": "Corning",
    "ModelNumber": "6765/C1501",
    "SerialNumber": "",
    "BookValue": "0",
    "Location": "San Francisco, CA",
    "ServiceStatus": "",
    "Condition": "",
    "Category": "Centrifuge",
    "Catalog": "Default",
    "Selected": "0",
    "AvailForRedeploy": "/Date(1485849600000)/"
  },
  {
    "Id": "5b1600409fc4a04a1001af6b",
    "HitNumber": "2169956",
    "Title": "Centrifuge",
    "ClientIdNumber": "",
    "Status": "Requested",
    "IsVisible": false,
    "Manufacturer": "Corning",
    "ModelNumber": "6765/C1501",
    "SerialNumber": "",
    "BookValue": "0",
    "Location": "San Francisco, CA",
    "ServiceStatus": "",
    "Condition": "",
    "Category": "Centrifuge",
    "Catalog": "Default",
    "Selected": "0",
    "AvailForRedeploy": "/Date(1485849600000)/",
  },
  {
    "Id": "5b1600409fc4a04a1001af70",
    "HitNumber": "2169961",
    "Title": "Pipettes",
    "ClientIdNumber": "",
    "Status": "Available",
    "IsVisible": true,
    "Manufacturer": "Sartorius",
    "ModelNumber": "Picus / Tacta",
    "SerialNumber": "",
    "BookValue": "0",
    "Location": "San Francisco, CA",
    "ServiceStatus": "",
    "Condition": "",
    "Category": "Pipettes",
    "Catalog": "Default",
    "Selected": "0",
    "AvailForRedeploy": "/Date(1485849600000)/",
  }
];

grid = $("#jqgrid").jqGrid({
  data: mydata, //insert data from the data object we created above
  datatype: 'local',
  ajaxGridOptions: {
    contentType: 'application/json; charset=utf-8'
  },
  height: 'auto',
  colNames: ['Id', 'Serial', 'Title', 'AvailForRedeploy'],
  colModel: [{
      name: 'Id',
      index: 'Id',
      hidden: true,
    },
    {
      name: 'HitNumber',
      index: 'Hit #',
      sortable: true,
      search: true
    },
    {
      name: 'Title',
      index: 'Title',
      sortable: true,
    },
    {
      name: 'AvailForRedeploy',
      index: 'AvailForRedeploy',
      formatter: 'date',
      formatoptions: {
        srcformat: "ISO8601Long",
        newformat: "m/d/Y h:i A"
      },
      sortable: true,
    }
  ],
  rowNum: 25,
  rowTotal: 2000,
  loadonce: true,
  rowList: [25, 50, 100],
  pager: '#pjqgrid',
  sortname: 'id',
  toolbarfilter: true,
  viewrecords: true,
  sortorder: "asc",
  caption: "",
  multiselect: true,
  multiboxonly: true,
  autowidth: true,
  toolbar: [true, "both"],
});

$("#jqgrid").filterToolbar({
  stringResult: true,
  searchOnEnter: false
});

【问题讨论】:

    标签: jqgrid


    【解决方案1】:

    您遇到的问题在于 colModel 中的定义,尤其是 index 属性。

    此属性不能具有空格值。此外,定义时的索引属性用于搜索。你的定义是:

    {
        name: 'HitNumber',
        index: 'Hit #',
        sortable: true,
        search: true
    },
    

    这是不正确的。为了使它起作用,请设置数据中使用的名称:即

    {
        name: 'HitNumber',
        index: 'HitNumber,
        sortable: true,
        search: true
    },
    

    更多关于 colModel 选项 index 您可以阅读我们的documentation here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-27
      • 1970-01-01
      • 1970-01-01
      • 2013-05-21
      • 1970-01-01
      • 2013-01-14
      • 1970-01-01
      相关资源
      最近更新 更多