PDA

View Full Version : Json Update to MySQL with PHP



just.forever215
3 Dec 2010, 9:26 AM
var ListStore = new Ext.data.Store({
model: 'Contact',
proxy: {
type: 'ajax',
url : '../store.php',
reader: {
type: 'json',
}
},
getGroupString : function(record) {
// Group by the last name
return record.get('lastName')[0];
},
autoSave: true,
autoLoad: true,
writer: new Ext.data.JsonWriter({
encode: false,
writeAllFields: true
}),

});

var tpl = new Ext.XTemplate(
'<div class="x-list-item-body" style="-webkit-column-count: 2;">',
'<div class="contact" colindex="0" >',
'<strong>{firstName}</strong>',
' {lastName}',
'</div>',
'<div colindex="1">',
'<input type="button" id="btn1" value="" class="<tpl if="this.isTrue(value) == 1">on</tpl><tpl if="this.isTrue(value) == 0">off</tpl>" onclick="togglestyle(this)"/>',
'<input type="button" id="btn2" value="" class="<tpl if="this.isTrue1(value1) == 1">on</tpl><tpl if="this.isTrue1(value1) == 0">off</tpl>" onclick="togglestyle(this)"/> ',
'<input type="button" id="btn3" value="" class="<tpl if="this.isTrue2(value2) == 1">on</tpl><tpl if="this.isTrue2(value2) == 0">off</tpl>" onclick="togglestyle(this)"/> ',
'<input type="button" id="btn4" value="" class="<tpl if="this.isTrue3(value3) == 1">on</tpl><tpl if="this.isTrue3(value3) == 0">off</tpl>" onclick="togglestyle(this)"/></div>',
'</div>',
{
isTrue: function(value){
return value;
},
isTrue1: function(value1){
return value1;
},
isTrue2: function(value2){
return value2;
},
isTrue3: function(value3){
return value3;
}
}
);

var mmsTest=[
{

title: 'Simple',
layout: Ext.is.Phone ? 'fit' : {
type: 'vbox',
align: 'center',
pack: 'center'
},
cls: 'demo-list',
items: [{
width: Ext.is.Phone ? undefined : 300,
height: 500,
xtype: 'list',
store: ListStore,
itemTpl: tpl,/* '<div class="contact"><strong>{firstName}</strong> {lastName}<div><input type="button" id="btn" value="" class="off" onclick="togglestyle(this)" /></div></div>' */
}],

listeners: {
click: {
element: 'el', //bind to the underlying el property on the panel
fn: function(){ console.log('click el');
//ListStore.sync();
},
},
}
}

i read data use the store.php
how do i update the Mysql Data use the php

tomalex0
4 Dec 2010, 12:29 AM
Send an ajax request to some storesave.php, params as ListStore data

just.forever215
8 Dec 2010, 7:36 PM
i mean update use 'ListStore'
Use one Store to CRUD
Like i recently found Httpproxy api
but it don't work with sencha touch
so Someone can show me an example
for Sencha touch CRUD work with php Mysql