David
David

Reputation: 4281

Hww to change cell value of grid row

I have a grid in which one column have No value. I have a button I bbar. When I click on button I want that value to be changed to yes and complete grid to be strike. so far my code is :

{ 
xtype: 'button', 
text: 'Exclude',
handler : function(){
    var cohartgrid = Ext.getCmp('HART_GRID');
    var cohartstore = cohartgrid.getStore();
    var record = Ext.getCmp('HART_GRID').getSelectionModel().getSelected();
    var st = cohartstore.getRange();
    if(record.data.EXL == "No"){
        debugger;
       var abc = record.data.EXL
       abc.replace("Yes");
    }
}}

Here I want the value should replace yes to No fro UI and from Store.. (Also grid should be strike). I am trying for that.

Thanks in advance

Upvotes: 0

Views: 418

Answers (2)

UDID
UDID

Reputation: 2423

Try this,

I made answer as per your code.

{ 
    xtype: 'button', 
    text: 'Exclude',
    handler : function(){
    var cohartgrid = Ext.getCmp('HART_GRID');
   var cohartstore = cohartgrid.getStore();
   Ext.getCmp('HART_GRID').getSelectionModel().getSelected();
   var st = cohartstore.getRange();
   if(record.data.EXL == "No"){
   record.set("EXL","YES")
     }
     } 

    }

You need to replace the value at record level.

Upvotes: 1

Surya Prakash Tumma
Surya Prakash Tumma

Reputation: 2193

Here it is

bbar: [
        {
            text: 'Exclude',
            handler: function(){
                var selModel = grid.getSelectionModel();
                if(selModel.hasSelection()){
                    var record = selModel.getSelection()[0];
                    if(record.get('EXL') == "No")
                    record.set('EXL',"Yes");
                }
            }
        }
    ]

here is the working example check the fiddle click here

Upvotes: 1

Related Questions