Tutorial Extjs: Edit, Delete and Add File to Database
Today i will continue my previous tutorial about edit, delete file using extjs and php. And In this section we will learn about how to make function add file in extjs.
Below I only include a snippet from the sourcecode, for the full source code you can combine with the previous tutuorial.
create html code
1. index.html
after that create javascript file..
//.....
var simpleAdd = new Ext.FormPanel({
url:'simplegrid.php?act=add',
width: 340,
height:160,
frame: true,
labelWidth: 95,
defaults: {
allowBlank: false
},
items: [{
xtype: 'textfield',
fieldLabel: 'Name',
anchor: '70%',
name: 'name'
},
{
xtype: 'textfield',
fieldLabel: 'Address',
anchor: '70%',
name: 'address'
},
{
fieldLabel: 'Email',
anchor: '70%',
name: 'email',
xtype:'textfield',
vtype:'email'
}],
buttons: [{
text: 'Save',
handler: function(){
if(simpleAdd.getForm().isValid()){
simpleAdd.getForm().submit({
waitMsg: 'Uploading your photo...',
success: function(simpleAdd, o){
Ext.MessageBox.alert('Creation OK','Add file Success..');
SimpleDataStore.reload();
SimpleWindow.hide();
},
failure: function(simpleAdd, o){
Ext.MessageBox.alert('Warning','Add file Failur...');
}
});
}
}
},{
text: 'Reset',
handler: function(){
simpleAdd.getForm().reset();
}
}]
});
var SimpleWindow= new Ext.Window({
title: 'Form Add File',
closable:true,
closeAction:'hide',
width: 340,
height:160,
layout: 'fit',
modal: true,
items: simpleAdd
});
function displayFormWindow(){
if(!SimpleWindow.isVisible()){
SimpleWindow.show();
} else {
SimpleWindow.toFront();
}
}
//........
tbar:[
{
text:'Edit',
iconCls:'edit-grid',
handler: function()
{
var m = SimpleListingEditorGrid.getSelections();
if(m.length > 0)
{
formEdit.getForm().load({url:'simplegrid.php?act=get&id='+ m[0].get('id'), waitMsg:'Loading'});
window.show();
}
else
{
Ext.MessageBox.alert('Message', 'please... Choose one of file...!');
}
}
},'-',
{
text:'Delete',
iconCls:'delete',
handler: function()
{
var m = SimpleListingEditorGrid.getSelections();
if(m.length > 0){
Ext.MessageBox.confirm('Message', 'are you sure to delete this file?' , del);
}
else{
Ext.MessageBox.alert('Message', 'please... Choose one of file...!');
}
}
},'-',
{
text: 'Add',
iconCls:'add',
handler: displayFormWindow
}
],
after that create php file….
//....
else if($_GET["act"] == "add"){
$sql = "INSERT INTO simpleform (`id`,`name` ,`address` ,`email`) VALUES (NULL,'".$_POST["name"]."', '".$_POST["address"]."', '".$_POST["email"]."')";
mysql_query($sql) or die(mysql_error());
echo "{success:true}";
}
//....
below are some the screen shot of this tutorial


Tags: Alert Message, Amp, Anchor, Choose One, Creation, Delete File, Email, extjs, Failure, File Delete, Handler Function, HTML, JavaScript, Load Url, Photo, PHP, Snippet, Source code, Sourcecode, Success
Hello,
I tried your example. But the only portion thats is working is the Update. The Delete is not working. Is there any additional code aside from
function del(btn){
if(btn == ‘yes’){
var m = SimpleListingEditorGrid.getSelections();
SimpleDataStore.load({params:{del:m[0].get(“id”),start:0,limit:6}});
}
}
Thanks,
had recently herpes virus found in my blood. what I haveto do??? I’m in panic…
change this
SimpleDataStore.load({params:{del:m[0].get(”id”),start:0,limit:6}});
to this
SimpleDataStore.load({params:{del:m[0].get(“id”)}});
SimpleDataStore.load({params:{start:0,limit:6}});
Hi it is me.
I loose control!
No deposit casino accept USA players. Reputable online casino free No deposit casino accept USA players. Reputable online casino USA poker No deposit casino accept USA players. Top casino payout percentage casino No deposit casino accept USA players. Top casino payout percentage EURO Jackpot No deposit casino accept USA players. Top casino payout percentage Play No deposit casino accept USA players. Top casino payout percentage EURO blackjack No deposit casino accept USA players. Top casino payout percentage free No deposit casino accept USA players. Top casino payout percentage UK blackjack No deposit casino accept USA players. Top casino payout percentage free No deposit casino accept USA players. Top casino payout percentage US Jackpot Good night.
I have a problem please help me.
I have two gridpanel. gridpanel1 for inventory and gridpanel2 table to table history ..
how can I reply gridpanel2 display history data that contains code = code.gridpanel1
when I DoubleClick gridpanel1 the data appear in gridpanel2 where kode.gridpanel2 = the kode.gridpanel1
please help me..!!
When i execute add button on the grid, why the form on the window cannot show like textfield, button.
only the window blue screen show. Need your help! Thx.