2012-02-11 189 views
0

我想過濾dojo網格小部件中的數據,但是,我沒有運氣。過濾Dojo的網格中的數據dojox.grid.DataGrid

下面我發佈了我用來成功創建網格的JavaScript,但是,所有數據都顯示出來了。我試過用引號括住IsBaseLevel並用引號括起來,我似乎無法找到治療方法。與往常一樣,任何幫助或建議表示讚賞。如果您需要更多信息,請告訴我。

使用Javascript(減去dojo.ready到()函數調用):

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

,我發現我的問題。我期望過濾器在客戶端(瀏覽器)收到數據後應用到數據上。但是,在檢查網絡之後,我看到我的服務被調用了一個?IsBaseLevel = false查詢字符串。因此,您的Web服務將需要正確支持您將要應用於您的數據的任何標誌。

+0

我會當我2天的時間到了:x – Lucas 2012-02-12 04:20:26