martinrame
29 Jun 2012, 5:20 AM
I'm trying to implement a RowEditing plugin that has a column where the user can select data from a combobox.
This is the column definition for my combo box editor:
{
xtype: 'gridcolumn',
dataIndex: 'idproducto',
text: 'Producto',
editor: {
xtype: 'combobox',
store: 'Productos',
displayField: 'nombre',
valueField: 'idproducto',
mode: 'local',
selectOnFocus: true,
triggerAction: 'all'
}
},
As you can see, it references the store "Productos". Here it is:
Ext.define('MyApp.store.Productos', { extend: 'Ext.data.Store',
requires: [
'MyApp.model.Producto'
],
autoLoad: true,
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
pageSize: 30,
remoteSort: true,
remoteFilter: true,
buffered: true,
model: 'MyApp.model.Producto',
proxy: {
type: 'ajax',
api: {
read: '/cgi-bin/clientes.cgi/productos/read',
create: '/cgi-bin/clientes.cgi/productos/insert',
update: '/cgi-bin/clientes.cgi/productos/update',
destroy: '/cgi-bin/clientes.cgi/productos/delete'
},
reader: {
type: 'json',
idProperty: 'idproducto',
totalProperty: 'total',
successProperty: 'success',
root: 'root'
},
filterParam: 'query',
simpleSortMode: true
}
}, cfg)]);
}
});
The store references model Producto:
Ext.define('MyApp.model.Producto', { extend: 'Ext.data.Model',
idProperty: 'idproducto',
fields: [
{
name: 'idproducto',
type: 'int'
},
{
name: 'nombre'
},
{
name: 'version'
},
{
name: 'fabricante'
}
],
proxy: {
type: 'ajax',
url: '/cgi-bin/clientes.cgi/productos/read',
reader: {
type: 'json',
idProperty: 'idproducto',
totalProperty: 'total',
successProperty: 'success',
root: 'root'
},
filterParam: 'query',
simpleSortMode: true
}
});
When I open the Developer's tool window in Chrome, I can see in Network tab the request to /cgi-bin/clientes.cgi/productos/read, it returns this:
{ "root" : [
{
"fabricante" : "BBBB",
"version" : "3.1.1",
"idproducto" : 1,
"nombre" : "AAAA"
},
{
"fabricante" : "BBBB",
"version" : "3.2.1",
"idproducto" : 2,
"nombre" : "AAAA"
},
{
"fabricante" : "Brand",
"version" : "1.0.3.8",
"idproducto" : 3,
"nombre" : "G-RIS"
},
{
"fabricante" : "Brand",
"version" : "1.0",
"idproducto" : 4,
"nombre" : "G-PACS"
}
]
}
I've read many forums and examples, and it seems I'm doing everything corerrect, but it doesn't show the Productos list. What I'm doing wrong?.
This is the column definition for my combo box editor:
{
xtype: 'gridcolumn',
dataIndex: 'idproducto',
text: 'Producto',
editor: {
xtype: 'combobox',
store: 'Productos',
displayField: 'nombre',
valueField: 'idproducto',
mode: 'local',
selectOnFocus: true,
triggerAction: 'all'
}
},
As you can see, it references the store "Productos". Here it is:
Ext.define('MyApp.store.Productos', { extend: 'Ext.data.Store',
requires: [
'MyApp.model.Producto'
],
autoLoad: true,
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
pageSize: 30,
remoteSort: true,
remoteFilter: true,
buffered: true,
model: 'MyApp.model.Producto',
proxy: {
type: 'ajax',
api: {
read: '/cgi-bin/clientes.cgi/productos/read',
create: '/cgi-bin/clientes.cgi/productos/insert',
update: '/cgi-bin/clientes.cgi/productos/update',
destroy: '/cgi-bin/clientes.cgi/productos/delete'
},
reader: {
type: 'json',
idProperty: 'idproducto',
totalProperty: 'total',
successProperty: 'success',
root: 'root'
},
filterParam: 'query',
simpleSortMode: true
}
}, cfg)]);
}
});
The store references model Producto:
Ext.define('MyApp.model.Producto', { extend: 'Ext.data.Model',
idProperty: 'idproducto',
fields: [
{
name: 'idproducto',
type: 'int'
},
{
name: 'nombre'
},
{
name: 'version'
},
{
name: 'fabricante'
}
],
proxy: {
type: 'ajax',
url: '/cgi-bin/clientes.cgi/productos/read',
reader: {
type: 'json',
idProperty: 'idproducto',
totalProperty: 'total',
successProperty: 'success',
root: 'root'
},
filterParam: 'query',
simpleSortMode: true
}
});
When I open the Developer's tool window in Chrome, I can see in Network tab the request to /cgi-bin/clientes.cgi/productos/read, it returns this:
{ "root" : [
{
"fabricante" : "BBBB",
"version" : "3.1.1",
"idproducto" : 1,
"nombre" : "AAAA"
},
{
"fabricante" : "BBBB",
"version" : "3.2.1",
"idproducto" : 2,
"nombre" : "AAAA"
},
{
"fabricante" : "Brand",
"version" : "1.0.3.8",
"idproducto" : 3,
"nombre" : "G-RIS"
},
{
"fabricante" : "Brand",
"version" : "1.0",
"idproducto" : 4,
"nombre" : "G-PACS"
}
]
}
I've read many forums and examples, and it seems I'm doing everything corerrect, but it doesn't show the Productos list. What I'm doing wrong?.