2009-08-19 74 views
1

我有一個使用某些可編輯的dijit表單字段的dojo網格。一切都很好,直到我嘗試執行一個國家(多)選擇單元格作爲工具提示對話框;即顯示下拉按鈕,其打開填充有複選框陣列的工具提示對話框以選擇一個或多個國家。一旦選中並單擊確定,單元格應該更新爲所選國家/地區列表。很顯然,我會照顧稍後通過商店更新服務器。如何使用TooltipDialog(和DropDownButton)更新Dojo網格單元格值

我已經實現了一個國家選擇工具提示對話框,像這樣工作正常:

dojo.provide("CountrySelector"); 
dojo.declare(
    "CountrySelector", 
    [dijit.form.DropDownButton], 
    { 
     label: 'Countries', 
     dropDown: new dijit.TooltipDialog({ execute: function() { 
               console.log("EXECUTE : ", arguments[0]); 
               this.value = arguments[0].country; 
               }, href:'/cm/ui/countries' }), 

     postCreate: function() { 
      this.inherited(arguments); 
      this.label = this.value; 
      dojo.connect(this.dropDown, 'onClose', function() { console.log('close'); }); 

      console.log("CountrySelect post create", this); 

     }, 
    } 
); 

與網格單元的類型爲:

{ name: 'Countries',   field: 'targeting.countries',   editable: true, hidden: false, type:dojox.grid.cells._Widget, widgetClass: CountrySelector }, 

所有工作正常,但我不能瞭解如何更新單元格的內容並在存儲單元執行時進行存儲。同樣,我似乎沒有更新行的行ID。

任何想法?

感謝, 哈雷爾

回答

0

我沒有設置你的代碼的測試,但你應該能夠只是創建一個在你的小工具,返回值命名getValue的方法來做到這一點。

查看其他示例(如dojox.grid.cells.ComboBox)以瞭解getValue的外觀。

+0

從來沒有爲我工作。 對我來說,最終的解決方案(對於這個和其他的小錯誤)是爲了溝渠Dojo(我非常喜歡它)並且把所有東西都移到ExtJs。就穩定性和易用性而言,它就在前方。更不用說它實際上有適當的文檔。 雖然感謝您的幫助! – Harel 2009-09-21 08:42:03

1
//Layout: 
gridLayout: {rows: [{name: 'Coll Name',field: 'colField', type: dojox.grid.cells.ComboBox, editable:'true', width:'8%',options: [], alwaysEditing:false}]} 

//Grid Store: 
this.gridStore = new dojo.data.ItemFileReadStore({data: {items: data}}); 

// 
var setOptions = function(items, request){ 
    this.gridLayout.rows[0].options.push('Val 1','Val 2'); 
    this.gridLayout.rows[0].values.push('1','2'); 
    dojo.connect(this.gridLayout.rows[0].type.prototype.widgetClass.prototype, "onChange",this, "_onComboChange"); 
    } 

this.gridStore.fetch({onComplete: dojo.hitch(this,setOptions)}); 

_onComboChange: function (selectedOption) { 
    console.info("_onComboChange: ",selectedOption); 
}, 


// If you need to populate combos with different values you can use onItem 
var getArray = function(item, request){ 
    // populate one by one 
    // attach an event to each combo 
} 
this.gridStore.fetch({onItem: dojo.hitch(this,getArray)}); 
1

這是我用來更新我的網

var idx = yourGrid.getItemIndex(item); 
if (idx >- 1) { 
    yourGrid.updateRow(idx);   
} 

更多細節


每一行由其標識符標識

yourGrid.store.fetchItemByIdentity({ 
    identity: <yourIdentity>, 
    onItem: function(item){ 
     // Update your attributes in the store depending on the server response 
     // yourGrid.store.setValue(item, <attribute>,<value>); 
     var idx = yourGrid.getItemIndex(item); 
     if (idx >- 1) { 
      yourGrid.updateRow(idx);   
     } 
    } 
}); 
相關問題