PDA

View Full Version : Creating buttons on Sheet from JSON source



lazzurs
1 Feb 2011, 8:02 AM
Hello,

I am trying to create a number of buttons on an existing Ext.Sheet using a JSON data Store. I have pasted in the code for both below however after trying various methods to add the JSON items to the Store to create the buttons I am now cannot see what I am missing.




Ext.regModel('Category', {
fields: [{name: 'text', type: 'string'},]
});

var categoryStore = new Ext.data.Store({
model: 'Category',
storeId: 'categoryStore',
sorters: 'text',

getGroupString : function(record) {
return record.get('text')[0];
},


proxy: {
type: 'ajax',
url : '/products/get/categories/',
reader: {
type: 'json',
}
},

});



and then under Ext.setup



var categorysheet = new Ext.Sheet({
height: '300',
width: '600',
floating: false,
modal: false,
layout: {
type: 'vbox',
pack: 'center',
align: 'stretch'
},
defaults: {
layout: {
type: 'hbox',
},
xtype: 'button',
ui: 'round',
width: '150',
height: '75',
handler: this.getProducts,
defaults: {
flex: 1
}
},



As stated above I have tried getting the items from the JSON store into the Sheet in quite a few ways however nothing seems to be able to just add buttons to the sheet. If I specify the items in the Sheet manually they are created with the same JSON so I know this is not a syntax issue on the JSON side.

What am I missing to add items to a sheet using a JSON data store?

To be clear I am doing this as other users might add new products so the list of items in a category can be dynamic and I need a button for each to add the items to another list.

Thanks in advance for the help.

jestics
31 Jan 2012, 12:32 PM
Better late than never? Have you tried using Ext.decode to pass the json string into a variable and then creating a loop from that?