Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Delphi para la web (https://www.clubdelphi.com/foros/forumdisplay.php?f=51)
-   -   Paginar Grid Con Memory Proxy (ExtJS) (https://www.clubdelphi.com/foros/showthread.php?t=82798)

Neeruu 15-04-2013 04:07:01

Paginar Grid Con Memory Proxy (ExtJS)
 
Hola a todos....

Estoy tratando de paginar una grilla...
Mire en muchos ejemplos pero no puedo hacer andar la paginacion.
Mi Store:

Cita:

var StoreEgresoVehiculo=Ext.create('Ext.data.Store', {
storeId:'StoreEgresoVehiculo',
autoLoad: true,
fields:[{name:'Vehiculo' , type: 'string'},
{name:'Patente' , type: 'string'},
],
data:{'items':[]},
enablePaging:true,
pageSize :1,
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
El Store esta enlazado a una grid...
Cuando necesito mostrar los datos cargo un array y luego cargo el array al
store:

Cita:

StoreEgresoVehiculo.loadData(MyArrayData, false);
Automaticamente se muestran los datos en la grid.
Pero el panel de paginacion no carga las paginas.

Si defino los datos de antemano ejemplo:

Cita:

var MyArrayData = {
'items': [{Vehiculo:'AUTOMOVIL',Patente:'AD'},
{Vehiculo:'CAMION',Patente:'XX'}]
};
Cuando quiero mostrar los datos hago:

Cita:

StoreEgresoVehiculo.loadPage(1);
y se muestra correctamente...

Pero cargando los datos después (que se muestra mi pantalla) no logro que la grid pagine.
Por favor alguien podría darme un ejemplo o guiarme como puedo solucionarlo.

Gracias

Neeruu 15-04-2013 05:40:01

Código:

Ext.onReady(function(){

  var mydataGrid=[];
        var StoreEgresoVehiculo=Ext.create('Ext.data.Store', {
                storeId:'StoreEgresoVehiculo',
                autoLoad: true,
                fields:[
                                {name:'Vehiculo'        , type: 'string'},
                                {name:'Patente'                , type: 'string'},                                               
                                ],
          data:{'items':[]},
                buffered:true,
                enablePaging:true,
                pageSize :1,
                proxy: {
                        type: 'memory',
                        reader: {
                                type: 'json',
                                root: 'items'
                        }
                }       
        })  ;                       

        Grid = Ext.create('Ext.grid.Panel', {
                id:'sIDGrilla',
                title: 'Datos',
                titleAlign:'center',
                store: StoreEgresoVehiculo,
                flex:1,               
                columns: [
                        {        text: 'Veh\u00edculo',
                                dataIndex: 'Vehiculo',
                                align: 'left',
                                menuDisabled:true,
                                width:130,
                        },                               
                               
                        {        text: 'Patente',
                                dataIndex: 'Patente',
                                align: 'left',
                                menuDisabled:true,
                                width:130,                               
                        }                                                               
                        ],                       
                height:200,
                width: '100%',
                scroll:'vertical',
                loadMask: true,
                renderTo: Ext.getBody(),
                bbar:
                        Ext.create('Ext.PagingToolbar', {
                                store: StoreEgresoVehiculo,
                                displayInfo: true,
                                displayMsg: 'Mostrador Registros {0} - {1} de {2}',
                                emptyMsg: "No Hay Datos Para Mostrar",
                                items:[
                                        '-', {
                                        text: 'Cargar Datos.',                                                                               
                                        handler:
                                                function() {                         
                          mydataGrid.push({Vehiculo:'CAR',Patente:'XXX'});   
                          alert('Datos Cagados');
                                                },
                                        },
                                        {
                                        text: 'Paginar.',                                                                               
                                        handler:
                                                function() {
                        StoreEgresoVehiculo.loadData(mydataGrid,true);
                                                StoreEgresoVehiculo.loadPage(1);                               
                                                },                               
                                        },
                                        {
                                                text:'Pagina2',
                                                handler:
                                                        function(){                                                       
                                                        }
                                        }
                                ]                               

                        }),               
        });       
});

Alguien podría decirme porque no se carga las paginas? Que esta mal en el código?

Gracias.

Neeruu 05-04-2014 02:08:03

Hola a todos....

Despues de mucho tiempo encontre la solucion para poder paginar los datos en una grilla.


Adjunto un ejemplo...
Link

Y esta basado en este ejemplo...
http://blog.jardalu.com/2013/6/21/gr...g-extjs-sencha

Aca tenemos el ejemplo inspirador funcionando:
http://jsfiddle.net/jardalu/TE4ah/


Esto es todo...
Habia empezado este post hace un tiempo... y ahora me lo respondo...

Saluda Atte Neeruu!!!:)

Casimiro Notevi 05-04-2014 10:23:12

^\||/



.


La franja horaria es GMT +2. Ahora son las 13:44:31.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi