PDA

View Full Version : set the value of checkcolumn from mysql result



mohaskuar
19 Feb 2014, 9:07 AM
I have a checkbox inside a grid which works fine....but when a load the store I want some of the checkbox to have a value true.This is based on the value I get from php-mysql.The server return 1 or 0 to the model along with other column values,So I really want to check or uncheck the value of the checkbox based on the values(1,0)...here is how i try to achieve this..

my grid


{ xtype:'grid', title: ' Item',
store : 'VItem',

plugin:[cellEditing],
columns : [

{header: 'id', dataIndex: 'id',},
{header: 'Item Name', dataIndex: 'itemname',flex:0},
{xtype:'checkcolumn',header:'indoor?',dataIndex:'checkmi',width:55}
]

},


my model


extend: 'Ext.data.Model',
fields: [
'id', 'itemname','checkm',
{name:'checkmi',mapping:'checkm',convert:function(v,record){ if(v==1){ return true;
}else{return false;}
}

}


my server return vales id,itemname and checkm.

I have tried these .I dont know if it is the right way... my checkbox appear but they are unchecked even if the value sent back from the server is one.
please help

scottmartin
19 Feb 2014, 12:15 PM
I usually set the fields in the table as tiny int 0/1 and set the field to type int in the model and assign the field to the checkbox and done.

There should be no need for the t/f convert field.

mohaskuar
19 Feb 2014, 11:40 PM
thanks