View Full Version : [Ext 2.0rc1] Grid store 'load' event

27 Nov 2007, 7:49 AM
I'm having a small problem with a standard grid, getting its values out of an Ajax loaded JSON store.

The task is to calulate values for the grid in JS after loading the store but BEFORE displaying them in the grid.
The implementation above shows a pseudo example.

Apparently the 'load'-event handler of the store (for the value calculation) is called AFTER the grid is rendered with the initial values of the store loaded via the proxy.

A (bad) possible solution could be to wait for successful the store, calculate the values and then start rendering the grid. But doing so the page stays emtpy for the calculation time.

Any good ideas?

var entry = Ext.data.Record.create([
{name: 'example', type: 'string'},
{name: 'text', type: 'string'},
{name: 'value', type: 'string'} // the values to be calculated

// create the data store
var store = new Ext.data.Store({
// load using HTTP
url: 'algo1.php',
// the return will be XML, so set up a JSON reader
reader: new Ext.data.JsonReader({
root: 'rows'
}, entry),

store.on('load', function(e) {
// this should calculate the values BEFORE the values are displayed in the grid

// calculate store values here
// :
// : this may take a few seconds

// create the editor grid
var grid = new Ext.grid.EditorGridPanel({
store: store,
cm: cm,
renderTo: 'grid',
height: 400,
autoExpandColumn: 'text',
stripeRows: true,
title: 'Value calculation',
frame: true,
clicksToEdit: 2

// trigger the data store load
store.load({params: {
action: 'get_raw_values'