1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    81
    Vote Rating
    0
    Answers
    2
    mohaskuar is on a distinguished road

      0  

    Default Answered: set the value of checkcolumn from mysql result

    Answered: set the value of checkcolumn from mysql result


    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
    Code:
                       {    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
    Code:
      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

  2. 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.

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,154
    Vote Rating
    475
    Answers
    686
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    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.

  4. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    81
    Vote Rating
    0
    Answers
    2
    mohaskuar is on a distinguished road

      0  

    Default my mistake

    my mistake


    thanks

Thread Participants: 1

Tags for this Thread