Foros del Web » Programando para Internet » Javascript »

Establecer datos dinamicos entre php y javascript

Estas en el tema de Establecer datos dinamicos entre php y javascript en el foro de Javascript en Foros del Web. Hola, tengo un pequeño problema, actualmente estoy modificando un archivo javascript para que me muestre datos estaticos desde un archivo php que tiene una conexion ...
  #1 (permalink)  
Antiguo 13/02/2013, 11:29
 
Fecha de Ingreso: febrero-2013
Ubicación: Lima
Mensajes: 301
Antigüedad: 11 años, 2 meses
Puntos: 5
Establecer datos dinamicos entre php y javascript

Hola, tengo un pequeño problema, actualmente estoy modificando un archivo javascript para que me muestre datos estaticos desde un archivo php que tiene una conexion hacia una tabla en sql, sin embargo no me esta mostrando los datos, pero si el contenedor donde van los archivos.
les comparto el codigo para que me apoyen.

Ext.onReady(function(){

Ext.QuickTips.init();
var xg = Ext.grid;

var encode = false;
var local =true;

var proxy=new Ext.data.HttpProxy({url:'data.php'});
var reader = new Ext.data.JsonReader({
},[
{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'}
]
)
var store=new Ext.data.Store({
proxy:proxy,
reader:reader

});
store.load();

// 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();

//create the grid
var grid = new xg.EditorGridPanel({
ds: new Ext.data.GroupingStore({
store: store,
// use local data
//data: app.grid.dummyData,
//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

Tarea)');
},
editor: new Ext.form.TextField({
allowBlank: false
})
},{
header: 'Proyecto',
width: 20,
sortable: true,
dataIndex: 'project'
},{
header: 'Fecha de 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: 'Fecha de 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: 'Tiempo Estimado',
width: 20,
sortable: true,
dataIndex: 'estimate',
summaryType: 'sum',
renderer : function(v){
return v +' hours';
},
editor: new Ext.form.NumberField({
allowBlank: false,
allowNegative: false,
style: 'text-align:left'
})
},{
header: 'Precio',
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: 'Alternar',
tooltip: 'Alterna la visibilidad de la tabla de resumen',
handler: function(){summary.toggleSummaries();}
}],

frame: true,
width: 800,
height: 450,
clicksToEdit: 1,
collapsible: true,
animCollapse: false,
trackMouseOver: false,
//enableColumnMove: false,
title: 'MCI',
iconCls: 'icon-grid',
renderTo: document.body
});

});

// crear espacio para la aplicación
Ext.ns('app.grid');
// almacenar datos de prueba en el espacio de aplicación
app.grid.dummyData = [
{projectId: 100, project: 'Field Anchoring', taskId: 112, description:

'Integrate 2.0 Forms with 2.0 Layouts', estimate: 6, rate: 150,

due:'06/24/2007'},
{projectId: 100, project: 'Field Anchoring', taskId: 113, description:

'Implement AnchorLayout', estimate: 4, rate: 150, due:'06/25/2007'},
{projectId: 100, project: 'Field Anchoring', taskId: 114, description:

'Add support for multiple types of anchors', estimate: 4, rate: 150,

due:'06/27/2007'},
{projectId: 100, project: 'Field Anchoring', taskId: 115, description:

'Testing and debugging', estimate: 8, rate: 0, due:'06/29/2007'},
{projectId: 101, project: 'Single-level Grouping', taskId: 101,

description: 'Add required rendering "hooks" to GridView', estimate: 6,

rate: 100, due:'07/01/2007'},
{projectId: 101, project: 'Single-level Grouping', taskId: 102,

description: 'Extend GridView and override rendering functions', estimate:

6, rate: 100, due:'07/03/2007'},
{projectId: 101, project: 'Single-level Grouping', taskId: 103,

description: 'Extend Store with grouping functionality', estimate: 4, rate:

100, due:'07/04/2007'},
{projectId: 101, project: 'Single-level Grouping', taskId: 121,

description: 'Default CSS Styling', estimate: 2, rate: 100,

due:'07/05/2007'},
{projectId: 101, project: 'Single-level Grouping', taskId: 104,

description: 'Testing and debugging', estimate: 6, rate: 100,

ue:'07/06/2007'},
{projectId: 102, project: 'Summary Rows', taskId: 105, description:

'Ext Grid plugin integration', estimate: 4, rate: 125, due:'07/01/2007'},
{projectId: 102, project: 'Summary Rows', taskId: 106, description:

'Summary creation during rendering phase', estimate: 4, rate: 125,

due:'07/02/2007'},
{projectId: 102, project: 'Summary Rows', taskId: 107, description:

'Dynamic summary updates in editor grids', estimate: 6, rate: 125,

due:'07/05/2007'},
{projectId: 102, project: 'Summary Rows', taskId: 108, description:

'Remote summary integration', estimate: 4, rate: 125, due:'07/05/2007'},
{projectId: 102, project: 'Summary Rows', taskId: 109, description:

'Summary renderers and calculators', estimate: 4, rate: 125,

due:'07/06/2007'},
{projectId: 102, project: 'Summary Rows', taskId: 110, description:

'Integrate summaries with GroupingView', estimate: 10, rate: 125,

due:'07/11/2007'},
{projectId: 102, project: 'Summary Rows', taskId: 111, description:

'Testing and debugging', estimate: 8, rate: 125, due:'07/15/2007'}
];

gracias....!!!
  #2 (permalink)  
Antiguo 13/02/2013, 12:55
Avatar de hackjose  
Fecha de Ingreso: abril-2010
Ubicación: Edo Mexico
Mensajes: 1.178
Antigüedad: 14 años
Puntos: 131
Respuesta: Establecer datos dinamicos entre php y javascript

Te recomiendo que uses el resaltador de codigo
Saludos
  #3 (permalink)  
Antiguo 14/02/2013, 08:16
 
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

hola, gracias por responder sin embargo, no te entendi muy bien cuando me dices que use el resaltador de codigo, lo que sucede es que soy nuevo en el foro y con esto de javascript.
agradeceria puedas ser un poco mas especifico.
gracias
  #4 (permalink)  
Antiguo 14/02/2013, 11:05
Avatar de hackjose  
Fecha de Ingreso: abril-2010
Ubicación: Edo Mexico
Mensajes: 1.178
Antigüedad: 14 años
Puntos: 131
Respuesta: Establecer datos dinamicos entre php y javascript

Cuando publicas un nuevo tema tienes un textarea que tiene una barra de herramientas, bueno en la barra de herramientas hay un select que dice Highlight, tienes varias opciones si vas a usar PHP eliges php y te inserta en el textarea un codigo, en medio de ese codigo pones tu codigo para que sea mas facil de leer y por lo tanto alguien te pueda ayudar

Saludos
  #5 (permalink)  
Antiguo 14/02/2013, 11:49
 
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. ];

Etiquetas: dinamicos, establecer, js, php
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:43.