2017-04-17 39 views
0

我有一個Ext.grid.GridPanel鏈接到一個Ext.data.JsonStore的數據和Ext.grid.ColumnModel網格規格。extjs填充多個數據源的面板

我有10列。其中9個正在被json商店填充。由於它的數據是動態的,並且無法像其餘的那樣加載,所以我在最後一列出現問題。

該列要求首先加載其他數據存儲,並且一旦加載完成,我需要從這些列中提取數據並將該數據插入到我的json存儲中的列中以顯示在10列網格中。

`

var JSONSTORE = new Ext.data.JsonStore ({ 
    // Store Configs 
     autoLoad: true, 
     url: 'json_data_call.php', 
     baseParams: {action: 'read'}, 
    // Reader Configs 
     storeId: 'store1', 
     idProperty: 'store1', 
     root: 'data', 
     sortInfo: { 
      field: 'field_name', 
      direction: 'ASC' 
     }, 
     fields: [ 
      {name : 'field_name', type: 'string'}, 
      {name : 'field_name', type: 'string'}, 
      {name : 'field_name', type: 'int'} 
     ], 
     autoSave: false 
    }); 

JsonStore.on('exception',JsonSave,this); 

JsonStore.on('load',function(){ 


    autoDiagnosticsJsonStore.warn_err_loaded = true; 

    if(autoDiagnosticsJsonStore.warn_err_loaded) 
    { 
     console.log(autoDiagnosticsJsonStore); 
    }else{ 
     console.log('ERROR'); 
    } 

}); 


/* 
* ColumnModel 
*/ 
var ColumnModel = new Ext.grid.ColumnModel ({ 
    defaults: { menuDisabled: true }, 
    columns: [ 
     {header: 'Type', hideable: false, sortable: false, dataIndex: 'ERR_TYPE', 
      renderer: function(value, metaData, record, rowIndex, colIndex, store) { 
       if (record.data.ERR_TYPE == 'WARNING') { 
        metaData.css = 'cog_bg_orange'; 
       } 
       if (record.data.ERR_TYPE == 'ERROR') { 
        metaData.css = 'cog_bg_red'; 
       } 
       return value; 
      } 
     }, 
     {header: 'Item Found', hideable: false, sortable: false, dataIndex: 'ERR_MSG', width: 900, css: 'font-family: lucida console, monospace;'} 
    ] 
}); 

var errorGrid = new Ext.grid.GridPanel({ 
    id: 'nmerrorGrid', 
    enableColumnMove: false, 
    autoHeight: true, 
    xtype: 'grid', 
    ds: JsonStore, 
    cm: ColumnModel, 
    sm: new Ext.grid.RowSelectionModel({singleSelect: true}) 
}); 


$error_panel = " 

var errorPanel = new Ext.Panel({ 
    title: 'field_name', 
    collapsible: true, 
    anchor: '98%', 
    height: 300, 
    frame: true, 
    layout: 'fit', 
    items: [ errorGrid ] 
});` 

回答

0

如果我正確理解這一點,你想創造另一個字段中存儲記錄,一旦商店人口計算該字段。

如果您爲商店的記錄創建model,則可以使用該記錄的值創建一個字段calculated

實施例:

Ext.define('User', { 
    extend: 'Ext.data.Model', 
    fields: [{ 
     name: 'firstName', 
     type: 'string' 
    },{ 
     name: 'lastName', 
     type: 'string' 
    },{ 
     name: 'fullName', 
     calculate: function (data) { 
     return data.firstName + ' ' + data.lastName; 
     } 
    }] 
}); 

字段 '全名' 使用現有的記錄的值是建立。您可以將模型添加到商店(model: 'User')以取代fields配置。

+0

完美的幫助......謝謝 – smanunta