我正在尝试搜索我刚刚制作的网格。我尝试了LiveSearchGridPanel,但它太慢而且有问题。因此,我正在尝试在我正在使用的应用程序中的一些旧网格示例中构建一个不同的搜索。下面的代码取自我的示例,它使用:
fieldlabel:'Search',
将搜索放在 tbar 中,并按列过滤研究结果。
// search
{
xtype : 'combo',
enableKeyEvents : true,
fieldLabel : 'Search',
hideTrigger : true,
typeAhead : false,
editable : true,
listeners : {
'specialkey' : function(field, e) {
// pressing enter
if (e.keyCode == 13) {
if (field.lastValue != null|| field.lastValue != undefined) {
// if the search key isn't empty
var search = field.lastValue;
// remove old filter
if (store.isFiltered())
store.clearFilter(true);
// apply filter on fields selected
if (checked[0] == 1) {
if (checked[1] == 1)
if (checked[2] == 1)
store.filter([{
property : "admantN",
value : search,
anyMatch : true
}],
[{
property : "admant",
value : search,
anyMatch : true
}],
[{
property : "userN",
value : search,
anyMatch : true
}]);
else
store.filter([{
property : "admantN",
value : search,
anyMatch : true
}],
[{
property : "admant",
value : search,
anyMatch : true
}]);
else {
if (checked[2] == 1)
store.filter([{
property : "admantN",
value : search,
anyMatch : true
}],
[{
property : "userN",
value : search,
anyMatch : true
}]);
else
store.filter([{
property : "admantN",
value : search,
anyMatch : true
}]);
}
}
else {
if (checked[1] == 1)
if (checked[2] == 1)
store.filter([{
property : "userN",
value : search,
anyMatch : true
}],[{
property : "admant",
value : search,
anyMatch : true
}]);
else
store.filter([{
property : "admant",
value : search,
anyMatch : true
}]);
else
if (checked[2] == 1)
store.filter([{
property : "userN",
value : search,
anyMatch : true
}]);
}
search = "";
}
else {// if search key is blank remove old filters
if (store.isFiltered()) {
store.clearFilter();
}
}}}}// end listeners
},
// to select in which field search
{
xtype : 'checkboxgroup',
store : checked,
columns : 3,
vertical : false,
width : 250,
items : [
{
// Default searching field
boxLabel : 'Name',
checked : true
},
{boxLabel : 'Admant'},
{boxLabel : 'Username'}
],
listeners :
{
'change' :
// store checked field
function(th, newValue, oldValue) {
var ics = th.items.items;
for (i = 0; i < 3; i++) {
checked[i] = ics[i].checked;
}
}
}
},
// Refresh button
{
xtype : 'button',
text : 'Refresh',
icon : 'images/refresh.gif',
handler :
function() {
metodoA = "list";
// remove pending filters
if (store.isFiltered())
store.clearFilter(true);
// refresh data from the server
Ext.Ajax.request({
method : "GET",
url : ur + "admants?MetodoAD="+ metodoA + "&DBad=" + dbA,
timeout : 10000,
success :
function(response) {
var obj = null;
try {
obj = Ext.decode(response.responseText);
}
catch (error) {}
if (obj) {
store.loadData(obj);
}
else {
console.log('Invalid response');
}
},
failure :
function(response) {
alert("Refreshing request failed");
}
});}}]
// end toolbar's item
},// end tbar
复制此解决方案的唯一问题是我找不到任何使用 fieldlabel 和 tbar 搜索来定义搜索框的教程或手册,该搜索框仅在我按下回车按钮后才起作用,而不是“实时搜索”。
有人有任何提示吗?