質問

A grid has editable rows, connected to a store which has a proxy. It uses the api e.g.

proxy: {
            type: 'ajax',
            api: {
                create:  'dm/acct/new.php',
                read:    'dm/acct/read.php',
                update:  'dm/acct/update.php',
                destroy: 'dm/acct/rm.php'
            },
            extraParams: {
                sess: 2345
            },

If I add extraParms to the store's proxy e.g. {abc:123} as shown above, when I come to edit a field on a grid, that detail is accompanied by the record at the server with the value defined. I can inspect it in the read.php.

However, for testing, I tried replacing abc with an application level var, e.g.

{abc:RPA.app.A_GLOBAL_VAR}

results in

Uncaught TypeError: Cannot read property 'A_GLOBAL_VAR' of undefined - this surprised me since the var is declared at the Application level and I thought would be scoped and available. This error causes the application to fail to run at all.

I have got it working but I don't like my approach because I think it is using the wrong event and I have not been able to spot a more suitable one.

On the grid' cell dblClick event I have:

var sto = Ext.getCmp('acc_grid').getStore();
var proxy= sto.getProxy();
proxy.setExtraParam('abc', somevar );

I definitely get the value of abc:somvar server-side - so does what I want. I just think it is bad design/wrong event and wondered if there is a better way of attaching the extra param to the record when the update on an editable grid? I have looked at other examples but not stumbled across one that I have been able to relate to.

Many thanks

Kevin

役に立ちましたか?

解決

Listen to the CellEditor plugin edit event rather than the cell dblclick...

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.plugin.CellEditing

When you set your cell editing plugin...

 plugins: [
        Ext.create('Ext.grid.plugin.CellEditing', {
            clicksToEdit: 1,
            listeners:{
                edit:function(){ doSomething }
            }
        })
    ],
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top