Sigma Php Ajax framework, Ajax Components, GUI Builder
February 04, 2012, 03:28:49 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Sigma Grid 2.1 Tutorial 3 - Create, Read, Update and Delete on database  (Read 13297 times)
steven
Moderator
Hero Member
*****
Posts: 546



View Profile
« on: July 21, 2008, 02:59:38 AM »

In tutorial 2, we have talked about how to retrieve data from server/database and display them page by page. It seems to be insteresting. You don't think so? All right, let me let it be this time. Smiley
Let's go over some knowledges about stuff transfered between grid and server. Do you still memeber paging process : When a paging button(first, previous, next and last) is pressed,  sigma grid will send paging relevant info to server.
So does saving data. When save button pressed, sigma grid will send deleted, appended and updated rows to server. The data structure looks like



As you can see, those deleted, appended and updated rows are right there.
« Last Edit: October 23, 2008, 02:37:42 AM by steven » Logged

Sigma AJAX Data Grid - Easy to Integrate with PHP, ASP Classic, ASP.NET & Java
Sigma PHP Ajax Framework - WYSIWYG GUI Builder With Tree, Grid, Treegrid, Dialog, Tab & More Component
steven
Moderator
Hero Member
*****
Posts: 546



View Profile
« Reply #1 on: August 04, 2008, 01:36:20 AM »

Do you remember how to convert these pretty string into php object? Right, we have a very powerful function named json_decode from PHP5.20. If you are using older version, you may need a third-party library, for example, Zend JSON at http://framework.zend.com/manual/en/zend.json.html. As we know, all the posted info is stored by post variable named _gt_json. The following two lines help us get the deleted records.

Here $deletedRecords is array of array/hash(JSON object), which depends on what format you feed grid with. Take hash for example, you can get all the order numbers of deleted rows with following lines.
« Last Edit: November 28, 2008, 05:08:44 AM by steven » Logged

Sigma AJAX Data Grid - Easy to Integrate with PHP, ASP Classic, ASP.NET & Java
Sigma PHP Ajax Framework - WYSIWYG GUI Builder With Tree, Grid, Treegrid, Dialog, Tab & More Component
steven
Moderator
Hero Member
*****
Posts: 546



View Profile
« Reply #2 on: August 04, 2008, 01:47:05 AM »

The thing left is to operate database with PHP API. To be more professional, I recomend you using a PHP framework, such as CakePHP, to make your application safe and stable. But in this tutorial, I still write bare sql to achieve it. Here are the whole code to delete rows.

It's really easy, isn't?
« Last Edit: November 28, 2008, 05:09:24 AM by steven » Logged

Sigma AJAX Data Grid - Easy to Integrate with PHP, ASP Classic, ASP.NET & Java
Sigma PHP Ajax Framework - WYSIWYG GUI Builder With Tree, Grid, Treegrid, Dialog, Tab & More Component
steven
Moderator
Hero Member
*****
Posts: 546



View Profile
« Reply #3 on: August 04, 2008, 02:11:57 AM »

By far, we have two php files, one for loading by page(see tutorial2), the other for deleting. The last but not least thing we need to do is to make saveUrl of grid point to the php file.

In fact, we could merge those two ones into a single file. But how can we determine whether grid is ask for data or posting data for saving? Ah, good question. We have a field reserved for this. See the definition of _gt_json and you will see first field is action. It could be load or save. 
« Last Edit: November 28, 2008, 05:10:15 AM by steven » Logged

Sigma AJAX Data Grid - Easy to Integrate with PHP, ASP Classic, ASP.NET & Java
Sigma PHP Ajax Framework - WYSIWYG GUI Builder With Tree, Grid, Treegrid, Dialog, Tab & More Component
cpb.sos
Newbie
*
Posts: 1


View Profile
« Reply #4 on: December 26, 2008, 02:37:10 PM »

Please.

I need a php structure sample to save data grid.

Thanks
Logged
steven
Moderator
Hero Member
*****
Posts: 546



View Profile
« Reply #5 on: December 26, 2008, 05:12:03 PM »

please see the structure at
http://www.sigmawidgets.com/products/sigma_grid2/docs/dataexchange.html
Logged

Sigma AJAX Data Grid - Easy to Integrate with PHP, ASP Classic, ASP.NET & Java
Sigma PHP Ajax Framework - WYSIWYG GUI Builder With Tree, Grid, Treegrid, Dialog, Tab & More Component
Darshan
Full Member
***
Posts: 36


View Profile
« Reply #6 on: December 31, 2008, 03:33:57 AM »

 ???I faced one problem here..
If i have 3-4 editable columns and when i edit one column and immediately i change other at that time it cant save the first column and directly goes to change for second column..
So, what i can do here to solve this?
Thanks in advance.......... Smiley
Logged
godfather21
Newbie
*
Posts: 1


View Profile
« Reply #7 on: November 07, 2011, 11:20:23 PM »

i have one problem,when i press save it does not save and it returns the old value.what can i do?
Logged
incaib
Newbie
*
Posts: 1


View Profile
« Reply #8 on: January 21, 2012, 01:55:38 PM »

Fabulous only one day put sigma grid in my site on with this tutorials. But i have a little problem. The tutorial three say over update and add but when i add a line in my table i can't edit text in blank line. And if select a grid with data i can't edit for update. I put on the code of example for delete. I need make all code for update and add? or exist for work in the grind in realtime? sorry my english. Good weekend all from Mallorca(Spain) IncaIB Pep Sanchez

SOLUTION ADD:

First when make column for example if you like edit column nombre add in the line this editor:{type:"text"}

var colsOption = [
     {id: 'nombre' , header: "Name" , width :50, editor:{type:"text"} },
}

and in this moment on edit all columns of Name and the code in php for save if you update any grid is this for my work reedit for your grid.




If any friend like test how functionally is this in my server test is
http://www.ibsegundamano.es/admin/sigma/mydemo1.html
You can delete two or three or more lines and edit many line in one time and save at finish and go good thank's for this fabulous job all people. Bye.
« Last Edit: January 21, 2012, 03:22:27 PM by incaib » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!