-
Ext.foro.Nuevo
Mensajes: 11 Registrado: 09 Jun 2011, 06:17
|
 Publicado: 09 Feb 2012, 12:49
Finalmente, he decidido hacer un GroupingView, visualmente queda muchisimo mejor, ya que en lugar de ver un grid lleno de ceros y unos, estoy haciendo una agrupacion por nombre y muestro el valor que me interesa en el grid y despues por medio de un form muestro el resto de la informacion. ahora voy a tener el problema de integrarlo con el otro, aqui ahora tengo una duda, ya que lo programe haciendo un render en una pagina aparte y quiero integrarlo en el proyecto. Cuando lo meto en el JS principal al cargar la pagina me da lo de "b is null". en principio son dos grids independientes. estoy ejecutando una consulta en php y cuando obtengo la respuesta del servidor meto la info del json en el grid principal. el Grid.GroupingView es un grid secundario que en principio no tiene nada que ver con el primero, la idea era asociarle un evento a un boton y que me cargue el grid, he observado que si lo meto en el JS principal de la pagina, el servidor ya me devuelve el GET del json que voy a cargar en el segundo grid y eso es una carga un poco absurda, no? deberia de hacer el GET cuando ejecutara el boton y no al arrancar la pagina. como podria llamarlo desde un boton en un panel, por ejemplo, en la pagina principal? dejo codigo del Grid.GroupingView combinado con formulario para que muestre la info completa de un modo visualmente mas atractivo, por si a alguien le interesa. - Código: Seleccionar todo
Ext.onReady(function() { Ext.QuickTips.init(); Ext.form.Field.prototype.msgTarget = 'side'; var SpecieRecord = Ext.data.Record.create([ {name: 'Spice'}, {name: 'scientific_name', type:'string'}, {name: 'a_code', type: 'string'}, {name: 'spanish_name', type:'string'}, {name: 'portuguese_name', type:'string'}, {name: 'Food_use', type: 'string'}, {name: 'subject_en', type: 'string'}, {name: 'subject_es', type: 'string'}, {name: 'subject_pt', type: 'string'} ]); var storeSpecie = new Ext.data.GroupingStore({ url: 'data/valor_especie.json', autoLoad: true, reader: new Ext.data.JsonReader({ root: 'rows', idProperty: 'id' }, SpecieRecord), sortInfo:{field: 'Spice', direction: "ASC"}, groupField:'scientific_name' }); var Species = new Ext.form.FieldSet({ id:'Species', columnWidth: 0.2, labelWidth: 110, title: ' ', defaultType: 'textfield', autoHeight: true, bodyStyle: Ext.isIE ? 'padding:0 0 5px 5px;' : 'padding:5px 5px', border: false, style: { "margin-left": "10px", "margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "10px" }, items:[{ defaultType: 'textfield', fieldLabel: 'Alfa-3', width:40, name: 'a_code' },{ fieldLabel: 'Scientific Name', width:160, name: 'scientific_name' }] }); var Speciesname = new Ext.form.FieldSet({ id:'Speciesname', columnWidth:0.2, labelWidth:110, checkboxToggle:true, collapsed:false, title: 'Other Species Names', defaultType: 'textfield', autoHeight:true, bodyStyle: Ext.isIE ? 'padding:0 0 5px 5px;' : 'padding:5px 5px', border: true, style: { "margin-left": "10px", "margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "10px" }, items:[{ defaultType:'textfield', fieldLabel: 'Spanish Name', width:160, name: 'spanish_name' },{ defaultType: 'textfield', fieldLabel: 'Portuguese Name', width:160, name: 'portuguese_name' }] }); var use = new Ext.form.FieldSet({ id:'formulario2', columnWidth: 0.2, labelWidth: 110, title: ' ', defaultType: 'textfield', autoHeight: true, bodyStyle: Ext.isIE ? 'padding:0 0 5px 5px;' : 'padding:5px 5px', border: false, style: { "margin-left": "10px", "margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "10px" }, items:[{ defaultType: 'textfield', fieldLabel: 'Use', width:40, name: 'Food_use' },{ fieldLabel: 'Valorization', width:160, name: 'subject_en' }] }); var usevalore = new Ext.form.FieldSet({ id:'usevalore', columnWidth:0.2, labelWidth:110, checkboxToggle:true, collapsed:true, title: 'Other Species Valorization', defaultType: 'textfield', autoHeight:true, bodyStyle: Ext.isIE ? 'padding:0 0 5px 5px;' : 'padding:5px 5px', border: true, style: { "margin-left": "10px", "margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "10px" }, items:[{ defaultType:'textfield', fieldLabel: 'Spanish Name', width:160, name: 'subject_es' },{ defaultType: 'textfield', fieldLabel: 'Portuguese Name', width:160, name: 'subject_pt' }] }); var valoriza = new Ext.form.FieldSet({ id:'valiriza', columnWidth:0.2, labelWidth:140, title:'Species Valorization', defaultType: 'textfield', autoHeight: true, bodyStyle: Ext.isIE ? 'padding:0 0 5px 5px;' : 'padding:5px 5px', border: 'true', style: { "margin-left": "10px", "margin-right": Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "10px" }, items: [Species, Speciesname, use, usevalore] }); var SpecieForm = new Ext.FormPanel({ id:'SpecieForm', frame:true, labelAlign:'left', items:[valoriza] }); var gridvalor = new Ext.grid.GridPanel({ store: storeSpecie, columns:[{ id:'Spice', header: "Specie Name ", width:100, hidden:true, dataIndex:'scientific_name' },{ header: "Alfa-3", width: 50, sortable: false, align: 'right', hidden:true, dataIndex: 'a_code' },{ header: "Valorization", align: 'right', sortable: false, width:400, dataIndex: 'subject_en' }], view: new Ext.grid.GroupingView({ forceFit:false, //groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})' }), frame:true, width: 450, height: 600, collapsible: false, animCollapse: false, title: 'Species Valorization', iconCls: 'icon-grid', renderTo: 'docbody', stripeRows: true, singleSelect:true, listeners:{ rowclick:function(grid, index){ var st = grid.getStore(); rec= st.getAt(index); console.log(rec); ventanas.show(); Ext.getCmp("SpecieForm").getForm().loadRecord(rec); } }, }); var ventanas = new Ext.Window({ id:'ventanas', title: '', width: 600, height: 500, closeAction:'hide', items: SpecieForm, plain:true, buttons: [{ text:'Aceppt', handler: function(){ ventanas.hide(); } }] }); });
|