2011-05-20 28 views
1

我正在使用dojox.grid.EnhancedGrid的過濾器插件。其介紹是在http://dojotoolkit.org/reference-guide/dojox/grid/EnhancedGrid/plugins/Filter.html#dojox-grid-enhancedgrid-plugins-filterdojo EnhanceGrid的過濾器定義如何轉移到服務器端

而要實現服務器端的過濾器,它說:

默認情況下,在服務器端被認爲是無狀態(REST樣式)在這種情況下,你應該在過濾器定義發送到服務器。 ,與商店的讀取請求沿側您可以通過每store.fetch調用之前的時間修改請求對象做到這一點

,它給的示例代碼某些部分:

var grid = new dojox.grid.EnhancedGrid({ 
    id:"grid", 
    store:"mystore", 
    structure:"mystructure", 
    plugins:{ 
    filter: { 
     isServerSide: true, 
     setupFilterQuery: setupFilter 
    } 
    } 
}); 
var setupFilter = function(commands, request){ 
    //the commands object here is the same as the POSTed commands object for stateful server, see below. 
    if(commands.filter && commands.enable){ 
    //some filter is defined and valid. You can modify the request object here. 
    }else{ 
    //no filter is valid. 
    } 
}; 

從這個例子中,我仍然不知道如何將過濾器定義傳送到服務器端。 commands.filter是一個像樹一樣的json對象。它如何通過url參數傳遞給服務器端。有人可以給我一些示例代碼嗎?

問候 ZY

回答

2

您可以使用dojo.toJson序列化整個過濾,確定指標和評估它在服務器端
例如

request.query.filter=dojo.toJson(commands.filter); 

問候

+1

謝謝,dojo.toJson正是我想要的。我的dojo EnhancedGrid基於QueryReadStore。代碼將如下所示:request.serverQuery = {q:dojo.toJson(commands.filter)}; – ryan 2011-05-25 06:34:20

+0

你好。我發現commands.filter對象似乎不包含日期對象。用Firefox的調試器查看它,看起來它擁有一個數字(內存地址?),它應該有一個日期。你知道如何獲得日期嗎? – WoodenKitty 2013-10-23 04:26:25

+0

這個數字可能是millis代表的日期 - 處理日期沒有在json標準中解決 – 2013-10-28 10:41:56