2012-06-05 23 views
2

我在我的網格中使用它的組件列。如何設置組合的選項/動態存儲

我想爲每個用戶設置不同的商店。

如果在網格中有4個用戶,我想爲每個用戶設置不同的組合商店,以便當用戶點擊組合時,他將根據他的權限看到選項,或者我將設置的商店。

xtype: 'itscomponentcolumn', 
      text : '<b>Permission</b>', 
      width: 150, 
      dataIndex: 'permission', 
      items: function(value,record) { 
      return { 
       xtype: 'combobox', 
       store: [[0,'View Only'], [1,'View & Edit'], [2,'View,Edit & Delete'],[3,'No Access']], 
       //store:Combo_Store, 
       queryMode:'local', 
       displayField: 'display', 
       valueField: 'value', 
       name:'permission', 
       forceSelection:true, 
       width: 145, 
       listeners: { } 

我無法附加圖片。 試想一下,有5個記錄的網格。 網格有2列,用戶名,Permission列中的權限 我正在顯示組合,爲上面給出的代碼。

假設有vivek用戶,如果他只查看權限,那麼我只想在vivek記錄旁邊的組合中顯示視圖。

其他用戶也一樣。

我試圖使用bindStore設置商店,但沒有爲我工作。

請問我該怎麼做?

你的建議,我的代碼之後是這個樣子

xtype: 'itscomponentcolumn', 
      text : '<b>Permission</b>', 
      width: 250, 
      sortable:false, 
      dataIndex: 'permission', 
      items: function(value,record) { 
      return { 
       xtype: 'combobox', 
       store: new Ext.data.Store({ 
        proxy: { 
         type: 'ajax', 
         url: comboStoreURL+"&currenetUserId="+record.get("userId"), 
         reader: { 
          type: 'json', 
          root: 'jsonStore' 
         } 
        }, 
        autoLoad: true 
       }), 

但我能知道爲什麼每次給呼叫服務器?我的意思是每個記錄。我想一定有其他的方式來做到這一點,因爲我有我的網格商店的權限。

我的實際網格代碼是這樣的。

var store = Ext.create('Ext.data.Store', 
      { 
       storeId: 'ShareComponentStoreId', 
       fields: ['userId','userName','permission','isProjectOwner'], 
       proxy: { 
        type: 'ajax', 
        url:strURL, 
        reader: 
        { 
         root: 'rootShareGrid', 
         totalProperty: 'totalCount' 
        }, 
        writer: 
        { 
         type: 'json', 
         writeAllFields: false, 
         allowSingle: false, 
         encode: true, 
         root: 'row' 
        } 
       } 

      }); 


var shareGrid = Ext.create('Ext.grid.Panel', { 
      id: 'ShareComponentGrId', 
      enableColumnMove:false, 
      store: store, 
     columns: [ 
     { 
      text: '<b>Name</b>', 
      flex: 1,    
      sortable:false, 
      width: 100, 
      dataIndex: 'userName' 
     }, 
     { 
      xtype: 'itscomponentcolumn', 
      text : '<b>Permission</b>', 
      width: 250, 
      sortable:false, 
      dataIndex: 'permission', 
      items: function(value,record) { 
      return { 
       xtype: 'combobox', 
       store: new Ext.data.Store({ 
        proxy: { 
         type: 'ajax', 
         url: comboStoreURL+"&currenetUserId="+record.get("userId"), 
         reader: { 
          type: 'json', 
          root: 'jsonStore' 
         } 
        }, 
        autoLoad: true 
       }), 
       queryMode : 'local', 
       displayField: 'display', 
       valueField: 'value', 
       name:'permission', 
       forceSelection:true, 
       width: 200, 

因此,record.get('permission')具有該用戶的權限。

我想將該權限添加到組合商店。

即默認的combostore +用戶的權限。

希望我能在這裏解釋得很好。

請儘早回覆我

回答

0

當然有幾種方法可以做到這一點。 我會建議的是有一個權限商店與autoLoad:true。您可以立即獲取用戶權限,然後在網格加載時可用於組合框。

+0

你能告訴我這樣做的代碼嗎?我已經設置了autoLoad:true,對我的組合。 – Deepak

+0

你可以請我建議我在這裏做什麼? – Deepak

+0

將商店定義爲單獨的類並設置autoLoad:true。根據您的用戶標識從服務器填充數據。然後在您的組合框中使用該商店。數據將在您需要從組合中選擇某些內容時出現。如果這些信息不夠詳細,請說明什麼不起作用。 – dbrin

相關問題