PDA

View Full Version : Grid Panel with combobox in each cell of one column



theRedPill
10 Sep 2015, 6:37 PM
Hi all!

Currently I have a grid with an ArrayStore that I load with JSON items. Each record in the grid is a Message and each Message has an array of "To" objects. My goal is to be able to have each cell in the To column to be a combobox so that when the user clicks the To value of a Message, they can see all the To objects in that array.

Is this possible? A few of the threads I've seen describe a situation where they want to set the editor of a column to be a combobox with a static list of values. These examples do not really apply to my situation.


Just to be clear, the grid has an ArrayStore and the To field is of type 'auto'. Here is the column definition I've tried so far and it just displays [object Object], [object Object], .... inside of the cell:


{
text: 'To',
flex: 1,
dataIndex: 'tos',
editor: {

xtype: 'combobox',
store: new Ext.data.Store({
fields: [{
name: 'nodeId',
type: 'int'
}, {
name: 'nodeName',
type: 'string'
}]
}),
queryMode: 'local',
valueField: 'nodeId',
displayField: 'nodeName'
}}





Here's example JSON:


[{messageId: 21,
sender: 'JOHN SMITH',
tos: [{nodeId: 4, nodeName: "NODE NAME"}, {nodeId: 6, nodeName: "NODE NAME 2"}],
subject: "SUBJECT TEXT"
}, another message object]



Thanks for any help you guys can provide!!

joel.watson
16 Sep 2015, 11:29 AM
Hi--

Out of the box, there's no way to do this via configuration (at least not in Ext JS 4...in Ext JS 5+ you could use widgets). However, you might take a look at this user extension which seems to apply to what you're wanting:

https://www.sencha.com/forum/showthread.php?148064-Component-Column-Components-in-Grid-Cells

Thanks!
Joel

theRedPill
24 Sep 2015, 8:08 AM
Didn't have time to try this out before the feature was due so I just added a property to each record that held the first value of the array instead of showing all of them in a combo. I wish it worked out of the box but thanks for all your help guys