Código Javascript:
Ver original
/*! *Ag@l */ Ext.onReady(function(){ Ext.QuickTips.init(); var xg = Ext.grid; var reader = new Ext.data.JsonReader({ idProperty: 'taskid', fields: [ {name: 'projectid', type: 'int'}, {name: 'project', type: 'string'}, {name: 'taskid', type: 'int'}, {name: 'description', type: 'string'}, {name: 'estimate', type: 'float'}, {name: 'rate', type: 'float'}, {name: 'cost', type: 'float'} //{name: 'due', type: 'date', dateFormat:'m/d/Y'} //{name: 'x', type: 'date', dateFormat:'m/d/Y'} ], // configuración adicional para el control remoto root:'data', remoteGroup:true, remoteSort: true }); // definir una función de resumen personalizado Ext.ux.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){ return v + (record.data.estimate * record.data.rate); }; // utilizar extensión personalizada para Resumen del grupo var summary = new Ext.ux.grid.GroupSummary(); var grid = new xg.EditorGridPanel({ ds: new Ext.data.GroupingStore({ reader: reader, // utilizar los datos remotos proxy : new Ext.data.HttpProxy({ url: 'totals-hybrid.json', method: 'GET' }), //sortInfo: {field: 'due', direction: 'ASC'}, groupField: 'project' }), columns: [ { id: 'description', header: 'Tareas', width: 80, sortable: true, dataIndex: 'description', summaryType: 'count', hideable: false, summaryRenderer: function(v, params, data){ return ((v === 0 || v > 1) ? '(' + v +' Tareas)' : '(1 Tareas)'); }, editor: new Ext.form.TextField({ allowBlank: false }) },{ header: 'Proyecto', width: 20, sortable: true, dataIndex: 'project' }/*,{ header: 'Fecha Produccion', width: 25, sortable: true, dataIndex: 'x', summaryType: 'max', renderer: Ext.util.Format.dateRenderer('m/d/Y'), editor: new Ext.form.DateField({ format: 'm/d/Y' }) },{ header: 'Fecha Vencimiento', width: 25, sortable: true, dataIndex: 'due', summaryType: 'max', renderer: Ext.util.Format.dateRenderer('m/d/Y'), editor: new Ext.form.DateField({ format: 'm/d/Y' }) }*/,{ header: 'Duracion', width: 20, sortable: true, dataIndex: 'estimate', summaryType: 'sum', renderer : function(v){ return v +' horas'; }, editor: new Ext.form.NumberField({ allowBlank: false, allowNegative: false, style: 'text-align:left' }) },{ header: 'Valor', width: 20, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'rate', summaryType: 'average', editor: new Ext.form.NumberField({ allowBlank: false, allowNegative: false, style: 'text-align:left' }) },{ id: 'Cost', header: 'Total', width: 20, sortable: false, groupable: false, renderer: function(v, params, record){ return Ext.util.Format.usMoney(record.data.estimate * record.data.rate); }, dataIndex: 'cost', summaryType: 'totalCost', summaryRenderer: Ext.util.Format.usMoney } ], view: new Ext.grid.GroupingView({ forceFit: true, showGroupName: false, enableNoGroups: false, enableGroupingMenu: false, hideGroupedColumn: true }), plugins: summary, tbar : [{ text: 'Resumen', tooltip: 'Muestra el Resumen', iconCls: '', handler: function(){summary.toggleSummaries();} },'-',{ text: 'Guardar', tooltip: 'Guarda las Modificaciones Realizadas', iconCls: '', handler: function(){summary.toggleSummaries();} }], frame: true, width: 800, height: 450, clicksToEdit: 1, collapsible: true, animCollapse: false, trackMouseOver: false, //enableColumnMove: false, title: '::Agal::', iconCls: 'icon-grid', renderTo: document.body }); // cargar los datos remotos grid.store.load(); });
como se vera en la url de donde saca la info es un archivo json llamado totals-hybrid.json, el cual tiene esto en su interior:
Código Javascript:
Ver original
{ data: [ {projectId: 1, project: 'Filtro1', taskId: 101, description: 'Sub_filtro1', estimate: 6, rate: 150}, {projectId: 1, project: 'Filtro1', taskId: 102, description: 'Sub_filtro1', estimate: 4, rate: 150}, {projectId: 1, project: 'Filtro1', taskId: 103, description: 'Sub_filtro1', estimate: 4, rate: 150}, {projectId: 1, project: 'Filtro1', taskId: 104, description: 'Sub_filtro1', estimate: 8, rate: 0}, {projectId: 1, project: 'Filtro1', taskId: 105, description: 'Sub_filtro1', estimate: 8, rate: 125}, {projectId: 2, project: 'Filtro2', taskId: 106, description: 'Sub_filtro2', estimate: 6, rate: 100}, {projectId: 2, project: 'Filtro2', taskId: 107, description: 'Sub_filtro2', estimate: 6, rate: 100}, {projectId: 2, project: 'Filtro2', taskId: 108, description: 'Sub_filtro2', estimate: 4, rate: 100}, {projectId: 2, project: 'Filtro2', taskId: 109, description: 'Sub_filtro2', estimate: 2, rate: 100}, {projectId: 2, project: 'Filtro2', taskId: 110, description: 'Sub_filtro2', estimate: 6, rate: 100}, {projectId: 3, project: 'Filtro3', taskId: 111, description: 'Sub_filtro3', estimate: 4, rate: 125}, {projectId: 3, project: 'Filtro3', taskId: 112, description: 'Sub_filtro3', estimate: 4, rate: 125}, {projectId: 3, project: 'Filtro3', taskId: 113, description: 'Sub_filtro3', estimate: 6, rate: 125}, {projectId: 3, project: 'Filtro3', taskId: 114, description: 'Sub_filtro3', estimate: 4, rate: 125}, {projectId: 3, project: 'Filtro3', taskId: 115, description: 'Sub_filtro3', estimate: 4, rate: 125}, {projectId: 3, project: 'Filtro3', taskId: 116, description: 'Sub_filtro3', estimate: 10, rate: 125}, {projectId: 3, project: 'Filtro3', taskId: 117, description: 'Sub_filtro3', estimate: 8, rate: 125} ], summaryData: { 'Filtro1': {description: 14, estimate: 9, rate: 99, due: new Date(2009, 6, 29), cost: 999} } }
lo que deseo saber es como hacer para que el archivo json se conecte con SQL server y me muestre la tabla que deseo.
gracias