我有jqgrid:
jQuery("#list").jqGrid( {
url : 'ajax/get',
datatype : 'json',
mtype : 'POST',
colNames : [
'Date',
'ID'
],
colModel : [{
name : 'date',
index : 'date',
width : 60,
align : 'center',
searchoptions:{sopt:['gt', 'lt']}
},{
name : 'id',
index : 'id',
width : 40,
align : 'center',
searchoptions:{sopt:['eq']}
}]
//.......
});
有没有办法在“日期”栏中设置“odata”选项。现在它显示“更大”和“更少”。我需要 - “从”和“到”。
我试试这个:
colModel : [{
name : 'date',
index : 'date',
width : 60,
align : 'center',
searchoptions:{sopt:['gt', 'lt'], odata:['from', 'to']}
}
它不起作用,仍显示“更大”和“更少”。试过这个:
$(document).ready(function(){
$.jgrid.search = {
odata : ['equal','not equal', 'to', 'less or equal','from','greater or equal', 'begins with','does not begin with','is in','is not in','ends with','does not end with','contains','does not contain']
};
$.extend($.jgrid.search);
});
它在所有列中将“更大”替换为“从”和“更少”到“更换”,但我只需要在“日期”列中。有办法吗?
感谢。
答案 0 :(得分:1)
我遇到了类似的问题,最后通过编辑一些jqGrid源代码来解决它。
我在ops数组中添加了额外的运算符。 (这是版本4.4.0中的第6130行。)
ops : [
{"name": "eq", "description": "equal", "operator":"="},
{"name": "ne", "description": "not equal", "operator":"<>"},
{"name": "lt", "description": "less", "operator":"<"},
{"name": "le", "description": "less or equal","operator":"<="},
{"name": "gt", "description": "greater", "operator":">"},
{"name": "ge", "description": "greater or equal", "operator":">="},
{"name": "bw", "description": "begins with", "operator":"LIKE"},
{"name": "bn", "description": "does not begin with", "operator":"NOT LIKE"},
{"name": "in", "description": "in", "operator":"IN"},
{"name": "ni", "description": "not in", "operator":"NOT IN"},
{"name": "ew", "description": "ends with", "operator":"LIKE"},
{"name": "en", "description": "does not end with", "operator":"NOT LIKE"},
{"name": "cn", "description": "contains", "operator":"LIKE"},
{"name": "nc", "description": "does not contain", "operator":"NOT LIKE"},
{"name": "nu", "description": "is null", "operator":"IS NULL"},
{"name": "nn", "description": "is not null", "operator":"IS NOT NULL"},
{"name": "to", "description": "to", "operator":"<"},
{"name": "fr", "description": "from", "operator":">"}
],
numopts :
['eq','ne','lt','le','gt','ge','nu','nn','in','ni'],
stropts :
['eq','ne','bw','bn','ew','en','cn','nc','nu','nn','in', 'ni','to','fr'],
在日期列规范中的sopt参数中使用这些新选项。 (您可能还需要调整后端以根据搜索结果的实现来转换这些运算符。)
{name:'mydatefield', searchoptions: {sopt:['to', 'fr']}}
希望这有帮助。
答案 1 :(得分:0)
答案 2 :(得分:0)
在使用Chrome 31.x的Jquery 1.9 / 1.10中存在问题:不推荐使用event.returnValue。请改用标准的event.preventDefault()。 http://bugs.jquery.com/ticket/14320
替换以下代码(JQuery 2.x版本)=&gt;删除src.returnValue
// Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value.
this.isDefaultPrevented = (src.defaultPrevented ||
src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
可以为我工作