inel0910
15 Sep 2010, 11:36 PM
I'm using two combobox in row editor.
If user select 1st combobox's specific item,
2nd combobox's has to be a dynamic loading(different data store or http request address).
Code below
var sapStore = new Ext.data.Store({ // Use in editor
proxy: new Ext.data.HttpProxy({
url: '/' + ses.config.contextUrl + '/ws/admin/sap/selectServiceList?_type=json',
method:'GET'
}),
reader: new Ext.data.JsonReader({
root: 'sapservice',
fields: [{name: 'serviceId'}]
})
});
var boeStore = new Ext.data.Store({ // Use in editor
proxy: new Ext.data.HttpProxy({
url: '/' + ses.config.contextUrl + '/ws/admin/boe/selectServiceList?_type=json',
method:'GET'
}),
reader: new Ext.data.JsonReader({
root: 'boeservice',
fields: [{name: 'serviceId'}]
})
});
var sapServiceIdEditor = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
lazyRender:true,
mode: 'remote',
editable: false,
autoSelect: true,
valueField: 'serviceId',
displayField: 'serviceId',
store: sapStore
});
var colModel = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
{header: 'Report ID', dataIndex: 'reportId', width: 150, sortable: true,
editor: {xtype: 'textfield', allowBlank: false}},
{header: 'Report Name', dataIndex: 'reportName', width: 170, sortable: true,
editor: {xtype: 'textfield', allowBlank: false}},
{header: 'Status', dataIndex: 'status', width: 80, sortable: true,
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
if(value == 1)
return 'Active';
else if(value == 0)
return 'Inactive';
},
editor: new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
lazyRender:true,
mode: 'local',
editable: false,
autoSelect: true,
store: [[1, 'Active'], [0, 'Inactive']]
})
},
{header: 'Service Type', dataIndex: 'serviceType', width: 100, sortable: true,
editor: new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
lazyRender:true,
mode: 'local',
editable: false,
autoSelect: true,
store: [['boequery', 'boequery'], ['sap', 'sap']],
listeners: {
'select': function(combo, r, idx) {
//serviceIdEditor.destroy();
serviceIdEditor.clearValue();
var temp = Ext.getDom('serviceIdEditor');
//var temp = serviceIdEditor.getEl();
//serviceIdEditor.store.load({});
if(combo.getValue() == 'sap') {
//serviceIdEditor.store.removeAll();
//serviceIdEditor.reset();
serviceIdEditor.store.destroy();
serviceIdEditor.store = sapStore;
serviceIdEditor.store.load();
//serviceIdEditor.store.reload({});
}
else if(combo.getValue() == 'boequery') {
//serviceIdEditor.store.removeAll();
//serviceIdEditor.reset();
serviceIdEditor.store.destroy();
serviceIdEditor.store = boeStore;
serviceIdEditor.store.load();
//serviceIdEditor.store.reload({});
}
}
}
})
},
{header: 'Service ID', dataIndex: 'serviceId', width: 150, sortable: true,
//editor: {xtype: 'textfield', allowBlank: false}},
editor: serviceIdEditor},
{header: 'Report Type', dataIndex: 'reportType', width: 90, sortable: true,
editor: {xtype: 'textfield', allowBlank: false}},
{header: 'Description', dataIndex: 'description', width: 240, sortable: true, id: 'description',
editor: {xtype: 'textfield', allowBlank: true}},
{header: 'Layout File', dataIndex: 'layoutFile', width: 400, sortable: true,
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
if((value != "") && (value != null)) {
//var fileId = Ext.util.Format.substr(value, 32, value.length);
return '<a href="/' + ses.config.contextUrl + '/ws/attach/getAttachment/'+value+'">'+value+'</a>';
}
else
return "";
},
editor: {disabled: true}},
{header: 'Created', dataIndex: 'created', width: 120, sortable: true,
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
if((value == "") || (value == null)) {
return;
}
value = Ext.util.Format.substr(value, 0, 19);
var dt = Date.parseDate(value, 'Y-m-d\\TH:i:s');
return dt.format('Y-m-d H:i:s');
},
editor: {disabled: true}}
]);
See a 'Service Type' & 'Service ID' in column model
Thanks in advance &
Sorry for bad English.
If user select 1st combobox's specific item,
2nd combobox's has to be a dynamic loading(different data store or http request address).
Code below
var sapStore = new Ext.data.Store({ // Use in editor
proxy: new Ext.data.HttpProxy({
url: '/' + ses.config.contextUrl + '/ws/admin/sap/selectServiceList?_type=json',
method:'GET'
}),
reader: new Ext.data.JsonReader({
root: 'sapservice',
fields: [{name: 'serviceId'}]
})
});
var boeStore = new Ext.data.Store({ // Use in editor
proxy: new Ext.data.HttpProxy({
url: '/' + ses.config.contextUrl + '/ws/admin/boe/selectServiceList?_type=json',
method:'GET'
}),
reader: new Ext.data.JsonReader({
root: 'boeservice',
fields: [{name: 'serviceId'}]
})
});
var sapServiceIdEditor = new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
lazyRender:true,
mode: 'remote',
editable: false,
autoSelect: true,
valueField: 'serviceId',
displayField: 'serviceId',
store: sapStore
});
var colModel = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
{header: 'Report ID', dataIndex: 'reportId', width: 150, sortable: true,
editor: {xtype: 'textfield', allowBlank: false}},
{header: 'Report Name', dataIndex: 'reportName', width: 170, sortable: true,
editor: {xtype: 'textfield', allowBlank: false}},
{header: 'Status', dataIndex: 'status', width: 80, sortable: true,
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
if(value == 1)
return 'Active';
else if(value == 0)
return 'Inactive';
},
editor: new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
lazyRender:true,
mode: 'local',
editable: false,
autoSelect: true,
store: [[1, 'Active'], [0, 'Inactive']]
})
},
{header: 'Service Type', dataIndex: 'serviceType', width: 100, sortable: true,
editor: new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
lazyRender:true,
mode: 'local',
editable: false,
autoSelect: true,
store: [['boequery', 'boequery'], ['sap', 'sap']],
listeners: {
'select': function(combo, r, idx) {
//serviceIdEditor.destroy();
serviceIdEditor.clearValue();
var temp = Ext.getDom('serviceIdEditor');
//var temp = serviceIdEditor.getEl();
//serviceIdEditor.store.load({});
if(combo.getValue() == 'sap') {
//serviceIdEditor.store.removeAll();
//serviceIdEditor.reset();
serviceIdEditor.store.destroy();
serviceIdEditor.store = sapStore;
serviceIdEditor.store.load();
//serviceIdEditor.store.reload({});
}
else if(combo.getValue() == 'boequery') {
//serviceIdEditor.store.removeAll();
//serviceIdEditor.reset();
serviceIdEditor.store.destroy();
serviceIdEditor.store = boeStore;
serviceIdEditor.store.load();
//serviceIdEditor.store.reload({});
}
}
}
})
},
{header: 'Service ID', dataIndex: 'serviceId', width: 150, sortable: true,
//editor: {xtype: 'textfield', allowBlank: false}},
editor: serviceIdEditor},
{header: 'Report Type', dataIndex: 'reportType', width: 90, sortable: true,
editor: {xtype: 'textfield', allowBlank: false}},
{header: 'Description', dataIndex: 'description', width: 240, sortable: true, id: 'description',
editor: {xtype: 'textfield', allowBlank: true}},
{header: 'Layout File', dataIndex: 'layoutFile', width: 400, sortable: true,
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
if((value != "") && (value != null)) {
//var fileId = Ext.util.Format.substr(value, 32, value.length);
return '<a href="/' + ses.config.contextUrl + '/ws/attach/getAttachment/'+value+'">'+value+'</a>';
}
else
return "";
},
editor: {disabled: true}},
{header: 'Created', dataIndex: 'created', width: 120, sortable: true,
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
if((value == "") || (value == null)) {
return;
}
value = Ext.util.Format.substr(value, 0, 19);
var dt = Date.parseDate(value, 'Y-m-d\\TH:i:s');
return dt.format('Y-m-d H:i:s');
},
editor: {disabled: true}}
]);
See a 'Service Type' & 'Service ID' in column model
Thanks in advance &
Sorry for bad English.