Ver Mensaje Individual
  #5 (permalink)  
Antiguo 14/02/2013, 11:49
ambichol
 
Fecha de Ingreso: febrero-2013
Ubicación: Lima
Mensajes: 301
Antigüedad: 11 años, 2 meses
Puntos: 5
Respuesta: Establecer datos dinamicos entre php y javascript

ok gracias, ya entendi, les comparto el codigo para que puedan ayudarme.

Código Javascript:
Ver original
  1. /*!
  2.  * Ext JS Library 3.4.0
  3.  * Copyright(c) 2006-2011 Sencha Inc.
  4.  * http://www.sencha.com/license
  5.  */
  6. Ext.onReady(function(){
  7.  
  8.     Ext.QuickTips.init();
  9.  
  10.     var xg = Ext.grid;
  11.  
  12.     var reader = new Ext.data.JsonReader({
  13.         idProperty: 'taskId',
  14.         fields: [
  15.             {name: 'projectId', type: 'int'},
  16.             {name: 'project', type: 'string'},
  17.             {name: 'taskId', type: 'int'},
  18.             {name: 'description', type: 'string'},
  19.             {name: 'estimate', type: 'float'},
  20.             {name: 'rate', type: 'float'},
  21.             {name: 'cost', type: 'float'},
  22.             {name: 'due', type: 'date', dateFormat:'m/d/Y'}
  23.         ]
  24.  
  25.     });
  26.  
  27.     // define a custom summary function
  28.     Ext.ux.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){
  29.         return v + (record.data.estimate * record.data.rate);
  30.     };
  31.  
  32.     // utilize custom extension for Group Summary
  33.     var summary = new Ext.ux.grid.GroupSummary();
  34.  
  35.     var grid = new xg.EditorGridPanel({
  36.         ds: new Ext.data.GroupingStore({
  37.             reader: reader,
  38.             // use local data
  39.             data: app.grid.dummyData,
  40.             sortInfo: {field: 'due', direction: 'ASC'},
  41.             groupField: 'project'
  42.         }),
  43.         columns: [
  44.             {
  45.                 id: 'description',
  46.                 header: 'Task',
  47.                 width: 80,
  48.                 sortable: true,
  49.                 dataIndex: 'description',
  50.                 summaryType: 'count',
  51.                 hideable: false,
  52.                 summaryRenderer: function(v, params, data){
  53.                     return ((v === 0 || v > 1) ? '(' + v +' Tasks)' : '(1 Task)');
  54.                 },
  55.                 editor: new Ext.form.TextField({
  56.                    allowBlank: false
  57.                 })
  58.             },{
  59.                 header: 'Project',
  60.                 width: 20,
  61.                 sortable: true,
  62.                 dataIndex: 'project'
  63.             },{
  64.                 header: 'Due Date',
  65.                 width: 25,
  66.                 sortable: true,
  67.                 dataIndex: 'due',
  68.                 summaryType: 'max',
  69.                 renderer: Ext.util.Format.dateRenderer('m/d/Y'),
  70.                 editor: new Ext.form.DateField({
  71.                     format: 'm/d/Y'
  72.                 })
  73.             },{
  74.                 header: 'Estimate',
  75.                 width: 20,
  76.                 sortable: true,
  77.                 dataIndex: 'estimate',
  78.                 summaryType: 'sum',
  79.                 renderer : function(v){
  80.                     return v +' hours';
  81.                 },
  82.                 editor: new Ext.form.NumberField({
  83.                    allowBlank: false,
  84.                    allowNegative: false,
  85.                    style: 'text-align:left'
  86.                 })
  87.             },{
  88.                 header: 'Rate',
  89.                 width: 20,
  90.                 sortable: true,
  91.                 renderer: Ext.util.Format.usMoney,
  92.                 dataIndex: 'rate',
  93.                 summaryType: 'average',
  94.                 editor: new Ext.form.NumberField({
  95.                     allowBlank: false,
  96.                     allowNegative: false,
  97.                     style: 'text-align:left'
  98.                 })
  99.             },{
  100.                 id: 'cost',
  101.                 header: 'Cost',
  102.                 width: 20,
  103.                 sortable: false,
  104.                 groupable: false,
  105.                 renderer: function(v, params, record){
  106.                     return Ext.util.Format.usMoney(record.data.estimate * record.data.rate);
  107.                 },
  108.                 dataIndex: 'cost',
  109.                 summaryType: 'totalCost',
  110.                 summaryRenderer: Ext.util.Format.usMoney
  111.             }
  112.         ],
  113.  
  114.         view: new Ext.grid.GroupingView({
  115.             forceFit: true,
  116.             showGroupName: false,
  117.             enableNoGroups: false,
  118.             enableGroupingMenu: false,
  119.             hideGroupedColumn: true
  120.         }),
  121.  
  122.         plugins: summary,
  123.  
  124.         tbar : [{
  125.             text: 'Toggle',
  126.             tooltip: 'Toggle the visibility of summary row',
  127.             handler: function(){summary.toggleSummaries();}
  128.         }],
  129.  
  130.         frame: true,
  131.         width: 800,
  132.         height: 450,
  133.         clicksToEdit: 1,
  134.         collapsible: true,
  135.         animCollapse: false,
  136.         trackMouseOver: false,
  137.         //enableColumnMove: false,
  138.         title: 'Sponsored Projects',
  139.         iconCls: 'icon-grid',
  140.         renderTo: document.body
  141.     });
  142.  
  143. });
  144.  
  145. // set up namespace for application
  146. Ext.ns('app.grid');
  147. // store dummy data in the app namespace
  148. app.grid.dummyData = [
  149.     {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 112, description: 'Integrate 2.0 Forms with 2.0 Layouts', estimate: 6, rate: 150, due:'06/24/2007'},
  150.     {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 113, description: 'Implement AnchorLayout', estimate: 4, rate: 150, due:'06/25/2007'},
  151.     {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 114, description: 'Add support for multiple types of anchors', estimate: 4, rate: 150, due:'06/27/2007'},
  152.     {projectId: 100, project: 'Ext Forms: Field Anchoring', taskId: 115, description: 'Testing and debugging', estimate: 8, rate: 0, due:'06/29/2007'},
  153.     {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 101, description: 'Add required rendering "hooks" to GridView', estimate: 6, rate: 100, due:'07/01/2007'},
  154.     {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 102, description: 'Extend GridView and override rendering functions', estimate: 6, rate: 100, due:'07/03/2007'},
  155.     {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 103, description: 'Extend Store with grouping functionality', estimate: 4, rate: 100, due:'07/04/2007'},
  156.     {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 121, description: 'Default CSS Styling', estimate: 2, rate: 100, due:'07/05/2007'},
  157.     {projectId: 101, project: 'Ext Grid: Single-level Grouping', taskId: 104, description: 'Testing and debugging', estimate: 6, rate: 100, due:'07/06/2007'},
  158.     {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 105, description: 'Ext Grid plugin integration', estimate: 4, rate: 125, due:'07/01/2007'},
  159.     {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 106, description: 'Summary creation during rendering phase', estimate: 4, rate: 125, due:'07/02/2007'},
  160.     {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 107, description: 'Dynamic summary updates in editor grids', estimate: 6, rate: 125, due:'07/05/2007'},
  161.     {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 108, description: 'Remote summary integration', estimate: 4, rate: 125, due:'07/05/2007'},
  162.     {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 109, description: 'Summary renderers and calculators', estimate: 4, rate: 125, due:'07/06/2007'},
  163.     {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 110, description: 'Integrate summaries with GroupingView', estimate: 10, rate: 125, due:'07/11/2007'},
  164.     {projectId: 102, project: 'Ext Grid: Summary Rows', taskId: 111, description: 'Testing and debugging', estimate: 8, rate: 125, due:'07/15/2007'}
  165. ];