Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass parameter to Ext.data.Store?

Tags:

extjs

I am using following code:

var genres1 = new Ext.data.Store({
    reader: new Ext.data.JsonReader({
        fields: ['pincode','place_name'],
        root: 'rows'
    }),
   proxy: new Ext.data.HttpProxy({
        url: 'pointalong.php',
        method: 'GET'
   })
});

but i want to pass 3 parameters to my php file. how should i proccess? and also how would i get at php file.

like image 380
Pari Avatar asked Mar 13 '12 05:03

Pari


2 Answers

There are two possibilities. The first one is to use store baseParams config:

var genres1 = new Ext.data.Store({
    baseParams: {
        param1: 'value1',
        param2: 'value2'
    },
    // ...

The second one is to send them when you are using load method:

genres1.load({params: {param2: 'anotherValue'}});

Note: params will override any baseParams of the same name

So if you setup store with baseParams like in example above and then use load with params the store will request ...?param1=value1&param2=anotherValue.


... and also how would i get at php file

As usual variable passed via the URL parameters - using $_GET:

$param1 = $_GET['param1'];
like image 177
Molecular Man Avatar answered Oct 10 '22 00:10

Molecular Man


I use this and it works perfectly

Ext.define('store.odon.DiagnosticoStore', {
extend : 'Ext.data.Store',
model : 'model.odont.DiagnosticoModel',
    proxy: {
    type: 'ajax',
    api: {
        create: CONTEXT_PATH + '/mvc/odona/crear', 
        read: CONTEXT_PATH + '/mvc/odon/lista',
        update: CONTEXT_PATH + '/mvc/odon/update',
        destroy: CONTEXT_PATH + '/mvc/odon/delete'
    },
    reader: {
        type: 'json',
        root: 'diagnosticos',
        successProperty: 'success'
    },
    writer: {
        type: 'json',
        writeAllFields: true,
        encode: true,
        root: 'diagnosticos'
    }
}
});

the parameter is assigned to load the store

 var storeDiagnostico= getStore(); // Ext.create('store.odon.DiagnosticoStore');
        storeDiagnostico.getProxy().setExtraParam("idOdontologia", value);
        storeDiagnostico.load();
like image 21
Edy Aguirre Avatar answered Oct 10 '22 00:10

Edy Aguirre