form id="filterForm" Filter by Last Name: input type="text"name="filter" button type="submit"Filter/button/formdiv id="grid"/div require([ "dojo/dom", "dojo/on", "dojo/store/Memory", "dgrid/OnDemandGrid"],function(dom, on, Memory, OnDemandG
<form id="filterForm"> Filter by Last Name: <input type="text"name="filter"> <button type="submit">Filter</button> </form> <div id="grid"></div>
require([ "dojo/dom", "dojo/on", "dojo/store/Memory", "dgrid/OnDemandGrid" ],function(dom, on, Memory, OnDemandGrid) { varform = dom.byId("filterForm"), store = newMemory({ data: [ { id: 1, firstName: "Bryan", lastName: "Forbes"}, { id: 2, firstName: "Kenneth", lastName: "Franqueiro"}, { id: 3, firstName: "Colin", lastName: "Snover"}, { id: 4, firstName: "Kris", lastName: "Zyp"} ] }), grid = newOnDemandGrid({ columns: { "firstName":"First Name", "lastName":"Last Name" }, sort:"lastName", store: store },"grid"); on(form,"submit",function(event) { varvalue = form.elements.filter.value; // Filter lastName, matching against the input text grid.set("query", { lastName: value }); // Since we're using a form, prevent normal submission event.preventDefault(); }); }); 1 grid.set("query", { lastName: newRegExp(value, "i") });这种方式,结合使用JsonRest可以把filter参数通过url发送到后台,供条件查询使用,实现后台过滤 原文http://www.sitepen.com/blog/2013/09/06/dojo-faq-how-can-i-add-filtering-controls-to-dgrid/