Mir Gulam Sarwar
Mir Gulam Sarwar

Reputation: 2648

set default value of a column extjs

here, i have some columns in a grid and i want to give default value in the 'receivedquantity' field and by default the received quantity filed will be equal to "Quantity" field.if user edits the field then data will come from the database.I am using mvc pattern here...

this.columns=
    [
    {
    header:'name',
    dataIndex:'name'},
    {
    header:'Quantity',
    dataIndex:'quantity',
    },
    {
    header:'Received Quantity',
        dataIndex:'receivedquantity',
        selectOnFocus: true,
        filterable:true,
        renderer:function(val, meta, record){
        var receivedquantity = record.data.receivedquantity;
var quantity=record.data.quantity;
        if(receivedquantity==0)//by default receivedquantity=0
        {
        //set (receivequantity=quantity) in the grid's received quantity cell 
        }},
     editor: {allowBlank:false
     }
            }
                ];

Upvotes: 1

Views: 6484

Answers (1)

Amit Aviv
Amit Aviv

Reputation: 1816

renderer: function(val, meta, record){
    if(val) return val;
    return record.get('quantity');
}

Upvotes: 7

Related Questions