事实证明这很容易。您只需在网格上设置查询属性并调用 refresh()。
然后我必须对我的服务器端代码进行简单的更改来处理 ?search=whatever 查询字符串。
这是我的代码:
// assuming we have a declarative dijit/TextBox and a reference to our grid in myGrid
// wait for DOM before wiring up our textbox (when dijit parsed)
ready( function()
{
var timeoutId = null,
searchTextBox = registry.byId( 'searchTextBox' );
searchTextBox.watch( 'value', function( name, oldValue, newValue )
{
if( newValue.length == 1 )
{
return;
}
if( timeoutId )
{
clearTimeout( timeoutId );
timeoutId = null;
};
timeoutId = setTimeout( function()
{
myGrid.query = { search: newValue };
myGrid.refresh();
}, 300 );
} );
} );