1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    4
    Vote Rating
    0
    Javi Gallego is on a distinguished road

      0  

    Default Unanswered: checkcolumn false returns a NULL

    Unanswered: checkcolumn false returns a NULL


    I've a MVC schedule. When I do an update, the store->proxy fires an php file. But if the value of the checkcolumn is false then it sends a NULL value, so the UPDATE don't have the value. It works fine if the checkcolumn is true and I want to chage it to false. I've been looking for it in other threats but I didn't find nothing related with.

  2. #2
    Sencha User
    Join Date
    May 2011
    Location
    Ukraine, Rivne
    Posts
    250
    Answers
    44
    Vote Rating
    42
    redraid has a spectacular aura about redraid has a spectacular aura about redraid has a spectacular aura about

      0  

    Default


    Please provide config of model and column

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    4
    Vote Rating
    0
    Javi Gallego is on a distinguished road

      0  

    Default


    view
    Code:
    Ext.define("Bleext.f.view.TicketsGrid",{
        extend        : "Ext.grid.Panel",
    
    
        store        : "Bleext.f.store.Tickets",
        border        : false,
        rowEditor: Ext.create('Ext.grid.plugin.RowEditing', {
                clicksToEdit: 2
            }),
        initComponent    : function() {
            var me = this;
            me.columns = {
                items:[
                    {xtype: 'checkcolumn',header:"Ok",dataIndex:"Ok"},
                    {header:"Id_Article",dataIndex:"Id_Article",editor: 'textfield'}
                ],
              defaults: { flex: 1}
            };
    
    
            me.callParent();
            this.plugins = [ this.rowEditor ];
    }
    });
    model
    Code:
    Ext.define("Bleext.f.model.Ticket",{    extend      : "Ext.data.Model",    //<-- Herencia
    
    
        fields        : [
            {name:"Ok",type:"integer"},
            {name:"Id_Article",type:"integer"}
        ]
    });
    store
    Code:
    Ext.define("Bleext.f.store.Tickets",{
        extend        : "Ext.data.Store",
        model        : "Bleext.f.model.Ticket",
        autoSync: true,
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url : 'data/api.php',
            api: {
                create  : 'data/apiu.php',
                read    : 'data/api.php',
                update  : 'data/api.php?action=update',
                destroy : 'data/api.php'
            },
            reader: {
                type: 'json',
                root: 'data'
            },
            writer: {
                type: 'json',
                root: 'data',
                writeAllFields : true
            }
        }
        
    });
    When I click on the checkbox, the firebug writes that
    Code:
    ({"success":true,"data":{"Ok":true,"Id_Article":4369126}})
    php file

    Code:
    $r = json_decode($HTTP_RAW_POST_DATA,TRUE);
    		echo print_r($r);
    So, the Ok field don't have value so, after that the Update cannot work properly

    Array( [data] => Array ( [Ok] => [Id_Article] => 4369126 [id] => ))

  4. #4
    Sencha User
    Join Date
    May 2011
    Location
    Ukraine, Rivne
    Posts
    250
    Answers
    44
    Vote Rating
    42
    redraid has a spectacular aura about redraid has a spectacular aura about redraid has a spectacular aura about

      0  

    Default


    Try to change field config to:
    {name:"Ok",type:"boolean"},

  5. #5
    Sencha User
    Join Date
    Jul 2012
    Posts
    4
    Vote Rating
    0
    Javi Gallego is on a distinguished road

      0  

    Default


    I did, now if Ok old-value = false and new-value = true it works, because it returns me Ok=1, as you can see below.

    Code:
    Array(
    [data] => Array (
    [Ok] => 1 [Id_Article] => 4369126 [id] =>
    )
    )
    The problem comes when I want to change it from old-value = true to new-value = false, because it returns me Ok = (nothing or null), so my UPDATE doesn't work.

  6. #6
    Sencha User
    Join Date
    May 2011
    Location
    Ukraine, Rivne
    Posts
    250
    Answers
    44
    Vote Rating
    42
    redraid has a spectacular aura about redraid has a spectacular aura about redraid has a spectacular aura about

      1  

    Default


    PHP print_r function don't print false values -
    Code:
    redraid@office:~> cat test.php
    <?php
        $a = array(
            'false_key' => false,
            'true_key' => true,
        );
        
        print_r($a);
        var_dump($a);
    ?>
    redraid@office:~> php -f test.php 
    Array
    (
        [false_key] => 
        [true_key] => 1
    )
    array(2) {
      ["false_key"]=>
      bool(false)
      ["true_key"]=>
      bool(true)
    }
    The preferred method for accessing the raw POST data is php://input. $HTTP_RAW_POST_DATA is not available with enctype="multipart/form-data"
    PHP Code:
    <?php $postdata file_get_contents("php://input"); ?>
    PS. For debug ajax apps i recommend firebug+firephp

  7. #7
    Sencha User
    Join Date
    Jul 2012
    Posts
    4
    Vote Rating
    0
    Javi Gallego is on a distinguished road

      0  

    Default


    It works! Thanks a lot redraid .

Thread Participants: 1

Tags for this Thread