我想出了如何让它再次工作:
function getGridFilterBox(filterid, width, defaultvalue) {
// Returns a basic filter box that can be used to filter a grid
return {
id: filterid,
tag: 'input',
type: 'text',
size: width || 25,
value: defaultvalue || '',
cls: 'x-grid-filter'
}
}
function SetupGridFilter(filterid, gridToReload, ds) {
// Sets up the keyboard and parameter filtering for a basic filter box on a grid toolbar
var filter = Ext.get(filterid);
filter.on('keyup', function(e) {
var key = e.getKey(); // ENTER key filters, as does backspace or delete if the value is blank
if((key== e.ENTER)||((key == e.BACKSPACE || key == e.DELETE) && this.getValue().length == 0)) { reloadGrid(gridToReload); }
});
filter.on('focus', function(){this.dom.select();}); // setup an onfocus event handler to cause the text in the field to be selected
ds.on('beforeload', function() { ds.baseParams.searchPhrase = filter.getValue(); });
}
然后,在其他地方,在视口规范的中间:
thisGrid = new Ext.grid.GridPanel({
tbar: new Ext.Toolbar({items: ["-",
getGridFilterBox("myfilter")] }),
})
最后,在视口之后:
thisGrid.show();
SetupGridFilter("myfilter", thisGrid, gridData);