thank you for your quick reply, really appreciate it.
i understand what you mean. Gonna try to figure out how the save button works.
Keep up the good work, thanks for taking your time helping me. really appreciate it.
thank you for your quick reply, really appreciate it.
i understand what you mean. Gonna try to figure out how the save button works.
Keep up the good work, thanks for taking your time helping me. really appreciate it.
hi all,
i'm trying to do the save button but i can't seem to get it to work.
i can change fields, press ok, little red triangle appears but as soon as i click on save a little window shows up and it says "Unknown Error".
i have apache server + mysql
objName = bills (i assume this is the table name in my database)
idName = id (i assume this is the primairy key in my table)
url='php/database.php'
cmd='update'
in my database.php i do have a function called 'update' this is what it looks like:
i'm pretty sure here's where i go wrong. can someone please tell me what i'm doing wrong and give a kick in my rearend to the right direction i have to go to make this work?PHP Code:
function update()
{
$id = $_GET['id'];
$name = $_POST['name'];
$due = $_POST['due'];
$amount = $_POST['amount'];
$paid = $_POST['paid'];
$paid_when = $_POST['paid_when'];
$amount_paid = $_POST['amount_paid'];
if ($paid == 'true'){
$paid = '1';
} else {
$paid = '0';
}
$result="SELECT * FROM bills where id='$id'";
$result1=mysql_query($result);
$rows = mysql_fetch_array($result1);
$amount = $rows['amount'];
$difference = $amount_paid - $amount;
$query = "UPDATE bills SET name = '$name', due='$due', amount='$amount', paid='$paid', paid_when='$paid_when', amount_paid='$amount_paid', difference='$difference' WHERE id=$id";
$result3 = mysql_query($query);
echo '1';
}
thanks,
regards,
Robin30
firebug is giving me at least something,lol
i changed the name of id # 53 so that is correct, but still don't know how to get it changed in my database.PHP Code:
cmd update
data [{"name":"Penele","id":"53"}]
objName bills
regards,
robin30
Take php from demo page and adjust it. In each step test when it stops to work. BTW, I'd use PDO if possible - saves a lot of headaches.
Jozef Sakalos, aka Saki
Education, extensions and services for developers at new http://extjs.eu
News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy
i looked at the php file,
i'm using the same files as you do, Saki, now i get a message date or idname missing.
i'm loosing really sleep over this,![]()
.
i do have a different setup for the grid as you, if i use for example this.idName firefox goes ballastic.
so i made var out if it all.
this is my code for the grid:
the commitChanges i did put in a var too:PHP Code:
var grid = new Ext.grid.EditorGridPanel({
id:'lol',
enableColLock:false,
url:'php/database.php',
objName:'bills',
idName:'id',
// sm: new Ext.grid.RowSelectionModel({singlerow:true}),
width:700,
height:500,
ds: store,
cm: cm,
sm:sm,
plugins: [summary, action, new Ext.ux.grid.Search({
iconCls:'icon-zoom'
,readonlyIndexes:['all']
,disableIndexes:['amount'],
mode:'local',
position:'top',
align:'right'
}), recordForm],
trackMouseOver:false,
loadMask: true,
frame:false,
viewConfig: {
forceFit:true
},
bbar: new Ext.PagingToolbar({
pageSize: 15,
store: store,
displayInfo: true
}),
buttons:[{
text:'Save'
,iconCls:'icon-disk'
,scope:this
,handler: commitChanges
},{
text:'Reset'
,iconCls:'icon-undo'
,scope:this
,handler:function() {
this.store.rejectChanges();
}
}],
tbar:[{
text: 'Add Bill',
iconCls:'add',
tooltip: 'Add Bill',
handler: addbillform
},'-',{
text: 'Delete Bill(s)',
iconCls:'remove',
tooltip: 'Delete Selected Bill',
handler: deleteContextMenu
}
//,'-',{
// text: 'Pay Bill',
// iconCls:'money',
//tooltip: 'Pay Selected Bill',
// handler: paidbillform
//}
,'-']
});
ListingContextMenu = new Ext.menu.Menu({
id: 'ListingEditorGridContextMenu',
items: [
{ text: 'Pay Bill', iconCls:'money', handler: paidbillform },
{ text: 'Add Bill', iconCls:'add', handler: addbillform },
{ text: 'Delete Bill', iconCls:'remove', handler: deleteContextMenu }
// ,'-',
// { text: 'Print this grid', iconCls:'printer', handler: printListingContextMenu }
]
});
grid.addListener('rowcontextmenu', onListingEditorGridContextMenu);
because this.idName and this.objName didn't/doesn't work with me i please it all withPHP Code:
var commitChanges = function() {
var records = store.getModifiedRecords();
if(!records.length) {
return;
}
var data = [];
Ext.each(records, function(r, i) {
var o = r.getChanges();
if(r.data.newRecord) {
o.newRecord = true;
}
o[idName] = r.get('id');
data.push(o);
});
var o = {
url:'php/modified.php'
,method:'post'
,callback:requestCallback
,params:{
cmd:'saveData'
,objName:'bills'
,data:Ext.encode(data)
}
};
Ext.Ajax.request(o);
} // eo function commitChanges
var requestCallback = function(options, success, response) {
if(true !== success) {
this.showError(response.responseText);
return;
}
try {
var o = Ext.decode(response.responseText);
}
catch(e) {
this.showError(response.responseText, 'Cannot decode JSON object');
return;
}
if(true !== o.success) {
this.showError(o.error || 'Unknown error');
return;
}
switch(options.params.cmd) {
case 'saveData':
var records = store.getModifiedRecords();
Ext.each(records, function(r, i) {
if(o.insertIds && o.insertIds[i]) {
r.set('id', o.insertIds[i]);
delete(r.data.newRecord);
}
});
store.commitChanges();
break;
case 'deleteData':
break;
}
} // eo function requestCallback
var showError = function(msg, title) {
Ext.Msg.show({
title:title || 'Error'
,msg:Ext.util.Format.ellipsis(msg, 2000)
,icon:Ext.Msg.ERROR
,buttons:Ext.Msg.OK
,minWidth:1200 > String(msg).length ? 360 : 600
});
}
'id' and 'bills'
this is my php file:
[PHP]<?
// vim: ts=4w=4:nu:fdc=4:nospell
require("csql.php");
if(!isset($_POST["cmd"])) {
return;
}
$objects = array(
// {{{
// company
"bills"=>array(
"table"=>"bills"
,"idName"=>"id"
,"fields"=>array(
"id"
,"name"
,"due"
,"amount"
,"paid"
,"paid_when"
,"amount_paid"
,"difference"
)
)
// }}}
);
// create PDO object and execute command
$osql = new csql();
$_POST["cmd"]($osql);
// command processors
// {{{
/**
* getData: Outputs data to client
*
* @author Ing. Jozef Sak
I just played with the demo @ http://recordform.extjs.eu/ .
It looks good!
When I added a record via the regular add and then tried to delete it without entering any data into it, I couldn't delete it.
Delete is not implemented, anyway it is not part of the plugin.
Jozef Sakalos, aka Saki
Education, extensions and services for developers at new http://extjs.eu
News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy
I had a small issue when destroying and recreating the recordform object.
It took me hours to find out what is causing it. The following seems to fix it:
Replace
WithCode:var config = Ext.apply(this.defaultWindowConfig, this.windowConfig);
in the show-function.Code:var config={}; Ext.apply(config,this.defaultWindowConfig); Ext.apply(config, this.windowConfig);
What could be the reason? Any references to defaultWindow config that get overridden? Or you supply defaultWindowConfig? Or you re-use defaultWindowConfig?
Jozef Sakalos, aka Saki
Education, extensions and services for developers at new http://extjs.eu
News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy
Im not that deep into javascript. Could it be possible, that the defaultWindowConfig property is treated as class-property so that it is reused in the following instanciations? That would explain the strange behaviour, because you use an "applyIf" to assign the form item and listeners.
The effect I observed, was that on the second instance in the listeners the form and window properties where null.