1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    12
    Vote Rating
    0
    prnandaece is on a distinguished road

      0  

    Thumbs up Unanswered: how to set value for grid cell on beforeedit

    Unanswered: how to set value for grid cell on beforeedit


    how to set value for grid cell on beforeedit function?

    I want to evaluate some expression on beforeedit . The evaluated value will be disappeared when focusing a cell (i.e beforeedit). it will be appeared after out of cell focus (i.e afteredit).

    please some one help to fix this issue

    Thanks,

    My code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>Bcs</title>
    <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css">
    <link rel="icon" href="images/bcs.ico" />
    <script type="text/javascript" src="extjs/ext.js"></script>
    <script type="text/javascript" src="extjs/ext-all-debug.js"></script>
    <script type="text/javascript">

    Ext.onReady(function(){

    Ext.create('Ext.data.Store', {
    storeId:'simpsonsStore',
    fields:['qty', 'rate', 'amt'],
    data:{'items':[{"qty":10, "rate":13},{"qty":20, "rate":13},{"qty":30, "rate":14}]},
    proxy: {
    type: 'memory',
    reader: {
    type: 'json',
    root: 'items'
    }
    }
    });

    Ext.create('Ext.grid.Panel', {
    title: 'Simpsons',
    store: Ext.data.StoreManager.lookup('simpsonsStore'),
    columns: [
    {header: 'Qty', dataIndex: 'qty',
    editor: {
    xtype: 'numberfield',
    id:'qty-id',
    allowBlank: false
    }},
    {header: 'Rate', dataIndex: 'rate',
    editor: {
    xtype: 'numberfield',
    id:'rate-id',
    allowBlank: false
    }
    },
    {header: 'Amount', dataIndex: 'amt',
    editor: {
    xtype: 'numberfield',
    id:'amt-id',
    allowBlank: false
    }}
    ],
    selType: 'cellmodel',
    plugins: [
    Ext.create('Ext.grid.plugin.CellEditing', {
    clicksToEdit: 1,
    listeners : {

    'beforeedit' : function(e, data, fields, record) {


    if(e.grid.columns[(e.colIdx)].editor==undefined)
    {

    var GridCrntObj=e.grid.columns[(e.colIdx)].field;

    }
    else
    {

    var GridCrntObj=e.grid.columns[(e.colIdx)].editor;

    }
    if(GridCrntObj.id=="amt-id")
    {

    e.grid.store.data.items[e.rowIdx].data['amt']=(e.grid.store.data.items[e.rowIdx].data['qty']*e.grid.store.data.items[e.rowIdx].data['rate'])



    }

    e.grid.getView().refreshNode(e.rowIdx);



    },

    'afteredit':function(e, data, fields, record) {



    }

    }

    })
    ],
    height: 120,
    width: 303,
    renderTo: Ext.getBody()
    });

    });


    </script>

    </head>
    <body>

    </body>

    </html>

  2. #2
    Sencha User masoud_tamizy's Avatar
    Join Date
    Oct 2011
    Posts
    108
    Answers
    1
    Vote Rating
    0
    masoud_tamizy is on a distinguished road

      0  

    Default


    you can use blur event (onblur) in your listener ...
    Code:
    blur:function(me){
    		var code=me.getValue();
    		alert (code);				
    }

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    12
    Vote Rating
    0
    prnandaece is on a distinguished road

      0  

    Default


    here i am using cell editor . expression should be evaluated when focusing to the cell.

    anyway thanks your reply.

Thread Participants: 1

Tags for this Thread