defaultSearch 多个参数
时间: 2023-10-08 14:11:41 浏览: 47
`defaultSearch` 参数可以设置多个匹配方式,每个方式之间用空格分隔,例如:
```javascript
$('#grid').jqGrid('filterToolbar', {
stringResult: true,
searchOnEnter: false,
defaultSearch: "cn bw"
});
```
上述代码中,`defaultSearch` 参数设置了两种匹配方式,分别是包含(cn)和以开头为准(bw)。这样就可以在使用表头筛选时,选择不同的匹配方式进行筛选了。
同时,也可以通过在 `searchoptions` 属性中设置 `sopt` 参数,来指定该列使用的匹配方式,例如:
```javascript
colModel: [
{name: 'id', index: 'id', width: 50, searchoptions: {search: true, sopt: ['eq', 'ne']}},
{name: 'name', index: 'name', width: 100, searchoptions: {search: true, sopt: ['cn', 'bw']}},
{name: 'age', index: 'age', width: 80, align: "right", searchoptions: {search: true, sopt: ['gt', 'lt']}},
...
]
```
上述代码中,`sopt` 参数指定了每个列使用的匹配方式,例如第一列使用的是等于(eq)和不等于(ne)两种匹配方式。