2017-02-24 14 views
2

我有一個微件列標題由我選擇的值和過濾所述網格存儲。我想在網格標題上也完全一樣。因爲我給了一個組合值相同的值。如何給網格HEADR兩相同組合之一,並作爲一個網格列插件用於存儲濾波器

這裏是我的列標題代碼

header: { 
    items: [{ 
      xtype: 'combo', 
      displayField: "displayName", 
      fieldLabel: 'Some Label', 
      valueField: 'title', 
      displayField: 'title', 
      hidden : true, 
      queryMode: 'local', 
      value : 1, 
      autoSelect : true, 
      //dataindex:"MUTST", 
      store: { 
      fields: ["id", "displayName"], 
      data: [ 
        { "id": "1", "title": "Test1" }, 
        { "id": "2", "title": "Test2" }, 
        { "id": "3", "title": "Test3" } 
       ] 
      }, 
      listeners : { 
       select : function(combo , record , eOpts){ 
        debugger; 
        var sg = this.up("MyGrid"); 
        var col = sg.getColumns()[0]; // Getting Header column 
        var flit =sg.getColumns()[0].filter // Here I am getting object instead of constructor 
        //this.focus = sg.onComboFilterFocus(combo); 
       } 
      }, 
     }] 
}, 

我在列創建組件類型

MyColumn: function(headersXmlDoc) { 
    var me = this, 
     gridConfig = {}; 

    gridConfig.columns = []; 
    Ext.each(headersXmlDoc.getElementsByTagName("HEADER"), function(header) { 
     var column = { 
      text: header.getAttribute("L"), 
      dataIndex: header.getAttribute("DATAINDEX"), 
      sortable: (header.getAttribute("ISSORTABLE").toLowerCase()=="true"), 
      widgetType: header.getAttribute("WIDGET"), 
      filterType: Ext.isEmpty(header.getAttribute("FILTER"))? undefined: header.getAttribute("FILTER"), 
     }; 
     switch (header.getAttribute("WIDGET")) { 
      case 'textbox': 
       if(column.filterType){ 
        if(column.filterType == 'TagData'){ 
         column.filter = { 
          xtype: 'tagfield', 
          growMax : 10, 
          valueField: 'title', 
          displayField: 'title', 
          parentGrid : me, 
          dataIndex:header.getAttribute("DATAINDEX"), 
          queryMode: 'local', 
          multiSelect: true, 
          isFilterDataLoaded: false, 
          disabled: true, 
          listeners:{ 
           focus: me.SomeMethod, // 
          } 
         };       
        } 
       } 
       break; 

     } 
     this.columns.push(column); 
    }, gridConfig); 

    return gridConfig.columns; 
}, 

我想,如果我選擇在頭的組合,它會直接在窗口小部件組合選擇以及。任何人都可以解釋如何得到這個。在此先感謝

回答

0

所以你基本上需要在你的頭一個組合框,改變記錄值 - 的事實,你有一個小工具欄的網格單元其實並不重要,這裏內顯示的組合。

我想你是相當接近 - 但你試圖定義一個「頭」的配置和組合添加到其項目 - 而不是你只是直接定義的列項:

columns: [{ 
    text: 'Combo Test', 
    dataIndex: 'title', 
    items: [{ 
     xtype: 'combobox', 
     width: '100%', 
     editable: false, 
     valueField: 'title', 
     displayField: 'title', 
     queryMode: 'local', 
     autoSelect: true, 
     store: { 
      data: [{ 
       "id": "1", 
       "title": "Test1" 
      }, { 
       "id": "2", 
       "title": "Test2" 
      }, { 
       "id": "3", 
       "title": "Test3" 
      }] 
     }, 
     listeners: { 
      select: function (combo, selectedRecord) { 
       //we could just get the value from the combo 
       var value = combo.getValue(); 
       //or we could use the selectedRecord 
       //var value = selectedRecord.get('id'); 

       //find the grid and get its store 
       var store = combo.up('grid').getStore(); 

       //we are going to change many records, we dont want to fire off events for each one 
       store.beginUpdate(); 
       store.each(function (rec) { 
        rec.set('title', value); 
       }); 
       //finish "mass update" - this will now trigger any listeners for saving etc. 
       store.endUpdate(); 

       //reset the combobox 
       combo.setValue(''); 
      } 

     } 
    }], 
}, 

,實際的設定值的情況在選擇監聽器,你試圖 - 關鍵是要遍歷記錄並呼籲設置每一項:

//find the grid and get its store 
var store = combo.up('grid').getStore(); 

//we are going to change many records, we dont want to fire off events for each one 
store.beginUpdate(); 
store.each(function (rec) { 
    rec.set('title', value); 
}); 
//finish "mass update" - this will now trigger any listeners for saving etc. 
store.endUpdate(); 

我創建了一個小提琴顯示此工作: https://fiddle.sencha.com/#view/editor&fiddle/1r01

相關問題