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
awal6

form

Tags: , , , , , , , , , , , , , , , , , , ,

Incoming search terms for the article:

extjs iconCls , editing database from extjs formpanel , extjs window submit , updating extjs formpanel , getform extjs , extjs database , extjs editable grid php , iconcls extjs , extjs grid dblclick , extjs and Database , extjs grid database , extjs getForm() load , extjs grid submit , extjs window loading , extjs grid image delete , extjs window isvisible , extjs gridpanel url edit , extjs window examples , extjs grid getId , extjs tutorials add on , ExtJS this getForm() load({ , extjs textfield editable Grid , extjs textfield editable , extjs iconCls in window , extjs submit to delete , extjs rowexpander as editable grid , extjs reset file textfield , extjs remove iconCls , extjs iconcls user , Extjs window toFront , extjs xtype getform load , menampilkan database mysql dengan ext js 2 2 , PHP form add edit delete sql , php grid add delete and edit , php mysql jquery add edit update delete , php script for add edit delete , put top image extjs window , reload image in form panel after submit extjs , Row Edit Delete and Update javascript php , SimpleListingEditorGrid getSelections(); is not a function , update database after edit extjs , file upload handler using extjs , include html extjs , file upload extjs asp net , getForm() load extjs , getForm() load extjs grid , grid add edit delete update mysql with php jquery , GridPanel extjs edit , how to create ext window in asp net , how to edit grid in extjs extjs themes , extjs file upload , extjs theme , extjs upload , extjs upload file , extjs grid checkbox , extjs tutorial , extjs login , extjs login form , extjs grid paging exjs file upload , getForm() load({url:simplegrid php?act=get&id= m[0] get(id) waitMsg:Loading}); , extjs get grid row height , submit grid checkbox extjs , extjs grid checkbox submit , extJS login demo not work in 3 1 , upload xls file using extjs , extjs CheckboxSelectionModel color , extjs form load callback , upload file extjs tutorial 

6 Responses to “Tutorial Extjs: Edit, Delete and Add File to Database”

  1. Francis says:

    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,

  2. margohelp says:

    had recently herpes virus found in my blood. what I haveto do??? I’m in panic…

  3. Zam says:

    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}});

  4. 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.

  5. rosi says:

    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..!!

  6. Ricky Baratan says:

    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.

Leave a Reply

Security Code: