PDA

View Full Version : checkcolumn false returns a NULL



Javi Gallego
9 Jul 2012, 3:37 AM
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.

redraid
9 Jul 2012, 3:54 AM
Please provide config of model and column

Javi Gallego
9 Jul 2012, 5:58 AM
view


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

Ext.define("Bleext.f.model.Ticket",{ extend : "Ext.data.Model", //<-- Herencia


fields : [
{name:"Ok",type:"integer"},
{name:"Id_Article",type:"integer"}
]
});

store


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



({"success":true,"data":{"Ok":true,"Id_Article":4369126}})


php file




$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] => ))

redraid
9 Jul 2012, 6:33 AM
Try to change field config to:
{name:"Ok",type:"boolean"},

Javi Gallego
9 Jul 2012, 10:41 PM
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.




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.

redraid
9 Jul 2012, 11:37 PM
PHP print_r function don't print false values -

[email protected]:~> cat test.php
<?php
$a = array(
'false_key' => false,
'true_key' => true,
);

print_r($a);
var_dump($a);
?>
[email protected]:~> 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://www.php.net/manual/en/wrappers.php.php). $HTTP_RAW_POST_DATA (http://www.php.net/manual/en/reserved.variables.httprawpostdata.php) is not available with enctype="multipart/form-data"

<?php $postdata = file_get_contents("php://input"); ?>
PS. For debug ajax apps i recommend firebug+firephp (http://www.firephp.org/)

Javi Gallego
10 Jul 2012, 4:20 AM
It works! Thanks a lot redraid (http://www.sencha.com/forum/member.php?272942-redraid) .