我正在尝试过滤dojo网格小部件中的数据,但是,我没有运气。
下面我发布了用于成功创建网格的javascript,但是,显示了所有数据。我试过封闭IsBaseLevel引号和引号中的false,我似乎无法找到治愈方法。与往常一样,任何帮助或建议都表示赞赏。如果您需要更多信息,请告诉我。
Javascript(减去从dojo.ready到a()的函数调用):
var grid;
function a() {
var store = new dojox.data.JsonRestStore({ target: "/Services/Security/SecurityArea/", idAttribute: "id", syncMode: true });
var gridLayout = [
{ name: "Id", field: "Id" },
{ name: "Name", field: "Name" },
{ name: "Parent Id", field: "Parent", formatter: formatParent },
{ name: "Description", field: "Description"},
{ name: "IsBaseLevel", field: "IsBaseLevel"}];
grid = new dojox.grid.DataGrid({
store: store,
structure: gridLayout
}, document.createElement("div"));
grid.placeAt(dojo.body(), "last");
grid.startup();
grid.filter({ IsBaseLevel: false });
}
function formatParent(data) {
if (typeof data != "undefined" && data != null) {
var menu = new dijit.DropDownMenu({ style: "display: none;" });
menu.addChild(new dijit.MenuItem({
label: "Test 1",
iconClass: "dijitEditorIcon dijitEditorIconSave",
onClick: function () { alert('save'); }
}));
menu.addChild(new dijit.MenuItem({
label: "Test 1",
iconClass: "dijitEditorIcon dijitEditorIconCut",
onClick: function () { alert('cut'); }
}));
var button = new dijit.form.DropDownButton({
label: "hello!",
name: "programmatic2",
dropDown: menu
});
return button;
}
else return null;
}
JSON数据
[
{
"UtcCreated": "\/Date(1327877500038-0600)\/",
"UtcModified": "\/Date(1327877500038-0600)\/",
"UtcDisabled": null,
"CreatedBy": null,
"ModifiedBy": null,
"DisabledBy": null,
"Id": 4,
"Name": "/Home.aspx",
"Description": "The primary user home",
"IsBaseLevel": true,
"Parent": null
},
{
"UtcCreated": "\/Date(1327877500038-0600)\/",
"UtcModified": "\/Date(1327877500038-0600)\/",
"UtcDisabled": null,
"CreatedBy": null,
"ModifiedBy": null,
"DisabledBy": null,
"Id": 5,
"Name": "Security.GetSecurityAreas",
"Description": "Provides a list of security areas",
"IsBaseLevel": true,
"Parent": null
},
{
"UtcCreated": "\/Date(1327877500038-0600)\/",
"UtcModified": "\/Date(1327877500038-0600)\/",
"UtcDisabled": null,
"CreatedBy": null,
"ModifiedBy": null,
"DisabledBy": null,
"Id": 6,
"Name": "UI.GetDomObjects",
"Description": "Gets all the DOM objects for the client",
"IsBaseLevel": true,
"Parent": null
},
{
"UtcCreated": "\/Date(1327877500038-0600)\/",
"UtcModified": "\/Date(1327877500038-0600)\/",
"UtcDisabled": null,
"CreatedBy": null,
"ModifiedBy": null,
"DisabledBy": null,
"Id": 3,
"Name": "Test Security Area",
"Description": null,
"IsBaseLevel": false,
"Parent": {
"UtcCreated": "\/Date(1327877500038-0600)\/",
"UtcModified": "\/Date(1327877500038-0600)\/",
"UtcDisabled": null,
"CreatedBy": null,
"ModifiedBy": null,
"DisabledBy": null,
"Id": 4,
"Name": "/Home.aspx",
"Description": "The primary user home",
"IsBaseLevel": true,
"Parent": null
}
}
]
答案 0 :(得分:0)
我发现了我的问题。我希望在客户端(浏览器)收到数据后,将过滤器应用于数据。但是,在检查网络后,我看到我的服务是用?IsBaseLevel = false查询字符串调用的。因此,您的Web服务需要正确支持您将应用于数据的任何标志。