I am trying to filter data in the dojo grid widget, however, I am having no luck.
Below I have posted the javascript I use to successfully create the grid, however, all data is shown. I have tried enclosing IsBaseLevel is quotes and false in quotes, I cannot seem to find the cure. As always, any help or suggestions are appreciated. If you need more information, please let me know.
Javascript (minus the function call from dojo.ready to 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 Data
[
{
"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
}
}
]
I found my issue. I expected the filter to be applied on the data once it was received at the client (browser). However, after examining the network, I saw that my service was being called with a ?IsBaseLevel=false querystring. Thus, your web service will need to properly support any flags you will be applying upon your data.