views:

473

answers:

1

Hi i'm using Extjs and i have built a grid with editable cells. One of this cells must be a combobox that takes its options from a script that generates the json data. The code for the grid and for the combobox-cell-editor works but i want that the json request to the script is cached after the first time, is it possible?

I write some code, this is the part where i declare the combobox column in the grid constructor:

{
    dataIndex:"authors_name",
    id:"authors_name",
    header:"Authors",
    editable:true,
    sortable:true,
    editor:{
        xtype:"combo",
        allowBlank:false,
        editable:false,
        forceSelection: true,
        displayField: 'authors_name',
        valueField: 'authors_id',
        store:new Ext.data.JsonStore({
            proxy:new Ext.data.HttpProxy({
                //This is the json request to cache
                url: 'index.php?load=authors'
            }),
            root: 'items',
            fields: ['authors_name','authors_id']
        })
    }
}
+1  A: 

I've found the answer by posting on the ext forum, this is the solution if somebody is interested:

{
    dataIndex:"authors_name",
    id:"authors_name",
    header:"Authors",
    editable:true,
    sortable:true,
    editor:{
        xtype:"combo",
        allowBlank:false,
        editable:false,
        forceSelection: true,
        displayField: 'authors_name',
        valueField: 'authors_id',
        //Add mode and triggerAction properties to make it work locally
        mode:"local",
        triggerAction:"all",
        store:new Ext.data.JsonStore({
            proxy:new Ext.data.HttpProxy({
                url: 'index.php?load=categories&request=data&type=getAuthors'
            }),
            //Use the autoload property to do the request only one time
            autoLoad:true,
            root: 'items',
            fields: ['authors_name','authors_id']
        })
    }
}
mck89