EasyUI Forum
April 30, 2024, 06:27:10 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: how to save inline editing in database  (Read 7650 times)
ftmh
Newbie
*
Posts: 19


View Profile
« on: February 09, 2014, 05:04:51 AM »

hello every body:
how can save the inline editing ,please refer to this page :

http://jeasyui.com/demo/main/index.php?plugin=DataGrid&theme=default&dir=ltr&pitem=

the accept button just save the data in client side not send to data base! how can i do that?

thanks.....  Grin
Logged
arma
Full Member
***
Posts: 110


View Profile
« Reply #1 on: February 09, 2014, 11:07:36 AM »

Hi, this might help:

Code:
var grid = $('#mygrid');

//Commit any row changes
if (grid.datagrid.endEdit()) {
    grid.datagrid('acceptChanges');
}

var items = grid.datagrid('getRows'); //Get all grid rows and submit as array
$.post('url/to/save', {items: items}, function(r){
   if(r=='success'){
     //Response success code here
   }else{
     //Response Error here
   }
});

In php you simply can get the data with $_POST['items']. It's array so you can loop it to save to database.

Code:
$items = $_POST['items'];
foreach ($items as $key => $item) {
 //Process insert to table here $item['product'], $item['price'] and so on
}

echo 'success'; //Inform status back to browser
« Last Edit: February 09, 2014, 11:14:04 AM by arma » Logged
ftmh
Newbie
*
Posts: 19


View Profile
« Reply #2 on: February 09, 2014, 11:38:29 PM »

thanks, but is hat make JSON code to send data?
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!