ksandeepa
15 Feb 2012, 9:04 PM
I have a gridpanel and I want it to be editable having combobox. I need to populate this combobox with the values which is coming from parent store. All the examples I looked into refers to external store and that works. I have pasted my code for your reference.
Sample JSON
{
'success': true,
'results': [
{'sectionId': 'sectionId', 'sectionName': 'Section Name' ,'units': 'units', 'gradingBasis': 'gradingBasis','instructors': 'instructors', 'meetingTimes': [{'timeone':'Daft Punk'}],
'gradingBasisOptions' : [{'label': 'label1', 'value': 'val1'}, {'label': 'label1', 'value': 'val1'},{'label': 'label1', 'value': 'val1'}]},
{'sectionId': 'sectionId', 'sectionName': 'Section Name' ,'units': 'units', 'gradingBasis': 'gradingBasis','instructors': 'instructors', 'meetingTimes': [{'timeone':'Daft Punk'}]
]
}
and my view
Ext.define('studentenrollment.view.availableView', {
extend:'Ext.panel.Panel',
alias:'widget.availableView',
requires:['studentenrollment.store.availableStore',
'studentenrollment.model.availableModel',
'studentenrollment.controller.enrollmentController'
],
margins:'10 10 10 10',
width:'100%',
title:false,
autoScroll : false,
layout : 'fit',
items:[
{ id:'availableview-grid',
xtype :'grid',
store: 'availableStore',
autoScroll : true,
columns: [
{
xtype:'actioncolumn',
width:90,
sortable: false,
align : 'center',
id : 'addpreferenceAction',
items: [{
icon: 'ext-4.0/resources/themes/images/default/dd/drop-add.gif', // Use a URL in the icon config
tooltip: 'Add Preference'
}]
},
{text: "Section", width : 90, sortable: true, dataIndex: 'sectionName'},
{text: "Units", width: 90, sortable: true, dataIndex: 'units'},
{
text: "Grading Basis",
width: 90,
sortable: true,
dataIndex: 'gradingBasis',
editor: {
xtype: 'combobox',
typeAhead: true,
triggerAction: 'all',
selectOnTab: true,
store: [
['Shade','Shade'],
['Mostly Shady','Mostly Shady'],
['Sun or Shade','Sun or Shade'],
['Mostly Sunny','Mostly Sunny'],
['Sunny','Sunny']
],
lazyRender: false,
listClass: 'x-combo-list-small'
}
},
{text: "Instructor", width: 90, sortable: true, dataIndex: 'instructors'}
],
columnLines: false,
dockedItems: [{
xtype: 'toolbar',
items: ['Available','->',{
text:'Submit',
tooltip:'Add a new row',
iconCls:'add',
xtype : 'button'
}, '-', {
text:'Options',
tooltip:'Set options',
iconCls:'option'
}]
}],
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
frame: true,
title: false,
iconCls: 'icon-grid'
}
],
padding:1,
height:'100%',
id:'availableViewId'
});
My requirement is that I want to refer to parent store's gradingBasisOptions list to populate the combobox (something like store =
record.get('gradingBasisOptions
')
)
Thanks for help
Sample JSON
{
'success': true,
'results': [
{'sectionId': 'sectionId', 'sectionName': 'Section Name' ,'units': 'units', 'gradingBasis': 'gradingBasis','instructors': 'instructors', 'meetingTimes': [{'timeone':'Daft Punk'}],
'gradingBasisOptions' : [{'label': 'label1', 'value': 'val1'}, {'label': 'label1', 'value': 'val1'},{'label': 'label1', 'value': 'val1'}]},
{'sectionId': 'sectionId', 'sectionName': 'Section Name' ,'units': 'units', 'gradingBasis': 'gradingBasis','instructors': 'instructors', 'meetingTimes': [{'timeone':'Daft Punk'}]
]
}
and my view
Ext.define('studentenrollment.view.availableView', {
extend:'Ext.panel.Panel',
alias:'widget.availableView',
requires:['studentenrollment.store.availableStore',
'studentenrollment.model.availableModel',
'studentenrollment.controller.enrollmentController'
],
margins:'10 10 10 10',
width:'100%',
title:false,
autoScroll : false,
layout : 'fit',
items:[
{ id:'availableview-grid',
xtype :'grid',
store: 'availableStore',
autoScroll : true,
columns: [
{
xtype:'actioncolumn',
width:90,
sortable: false,
align : 'center',
id : 'addpreferenceAction',
items: [{
icon: 'ext-4.0/resources/themes/images/default/dd/drop-add.gif', // Use a URL in the icon config
tooltip: 'Add Preference'
}]
},
{text: "Section", width : 90, sortable: true, dataIndex: 'sectionName'},
{text: "Units", width: 90, sortable: true, dataIndex: 'units'},
{
text: "Grading Basis",
width: 90,
sortable: true,
dataIndex: 'gradingBasis',
editor: {
xtype: 'combobox',
typeAhead: true,
triggerAction: 'all',
selectOnTab: true,
store: [
['Shade','Shade'],
['Mostly Shady','Mostly Shady'],
['Sun or Shade','Sun or Shade'],
['Mostly Sunny','Mostly Sunny'],
['Sunny','Sunny']
],
lazyRender: false,
listClass: 'x-combo-list-small'
}
},
{text: "Instructor", width: 90, sortable: true, dataIndex: 'instructors'}
],
columnLines: false,
dockedItems: [{
xtype: 'toolbar',
items: ['Available','->',{
text:'Submit',
tooltip:'Add a new row',
iconCls:'add',
xtype : 'button'
}, '-', {
text:'Options',
tooltip:'Set options',
iconCls:'option'
}]
}],
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
frame: true,
title: false,
iconCls: 'icon-grid'
}
],
padding:1,
height:'100%',
id:'availableViewId'
});
My requirement is that I want to refer to parent store's gradingBasisOptions list to populate the combobox (something like store =
record.get('gradingBasisOptions
')
)
Thanks for help