如何使datepicker onselect函数在工具栏搜索和jqgrid中的高级搜索中有不同的工作方式 [英] How do make datepicker onselect function works differently in toolbar search and advanced search in jqgrid
本文介绍了如何使datepicker onselect函数在工具栏搜索和jqgrid中的高级搜索中有不同的工作方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望onselect事件仅在高级过滤器中而不在高级搜索中起作用.
I want the onselect event only do his job only on toolfilter not in advanced search.
这是我的网格:
$('#grid').jqGrid({
colNames: ['Title', 'date'],
colModel: [
{ name: 'Title', index: 'Title', searchoptions: { sopt: ['cn']} },
{ name: 'date', index: 'date', search: true, searchoptions: {
sopt: ['deq', 'dge', 'dlt'],
dataInit: function (el) {
$(el).datepicker({ onSelect: function (dateText, inst) { $("#grid")[0].triggerToolbar(); } });
}
}, width: 70
}
],
pager: jQuery('#pager'),
hidegrid: false,
sortname: "date",
sortorder: "desc",
rowNum: 20,
rowList: [10, 20, 50, 100],
autowidth: true,
width: "100%",
height: "100%",
datatype: 'json',
viewrecords: true,
mtype: 'POST',
url: '<url>'
})
预先感谢
推荐答案
例如,您可以使用以下事实:搜索工具栏内元素的id
将使用"gs_"
前缀进行构造.因此,实现可能与以下内容有关
You can for example use the fact that the id
of elements inside of searching toolbar will be cnstructed with "gs_"
prefix. So the implementation could be about the following
dataInit: function (elem) {
$(elem).datepicker({
changeYear: true,
changeMonth: true,
showButtonPanel: true,
onSelect: function () {
var $grid, grid;
if (typeof (elem.id) === "string" && this.id.substr(0, 3) === "gs_") {
// in case of searching toolbar
$grid = $(elem).closest('div.ui-jqgrid-hdiv')
.next('div.ui-jqgrid-bdiv')
.find("table.ui-jqgrid-btable:first");
if ($grid.length > 0) {
grid = $grid[0];
if ($.isFunction(grid.triggerToolbar)) {
setTimeout(function(){
grid.triggerToolbar();
}, 50);
}
}
} else {
// refresh the filter in case of
// searching dialog
$(this).trigger('change');
}
}
});
}
以非常接近的代码查看答案.
see the answer with very close code.
这篇关于如何使datepicker onselect函数在工具栏搜索和jqgrid中的高级搜索中有不同的工作方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文