|
shaynl
|
 |
« on: May 05, 2010, 04:26:27 AM » |
|
Is it possible to add auto save to the cells in the php grid when moving from one cell to another instead of needing to click on the save button? Thanks 
|
|
|
|
|
Logged
|
|
|
|
|
steven
|
 |
« Reply #1 on: May 10, 2010, 12:01:59 AM » |
|
yes,
|
|
|
|
|
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
|
|
|
|
shaynl
|
 |
« Reply #2 on: May 10, 2010, 06:28:49 AM » |
|
thanks, but where i put it in the code? 
|
|
|
|
|
Logged
|
|
|
|
|
steven
|
 |
« Reply #3 on: May 10, 2010, 07:13:40 AM » |
|
|
|
|
|
|
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
|
|
|
|
shaynl
|
 |
« Reply #4 on: May 11, 2010, 02:25:58 AM » |
|
still can't get it to work...  im geting error in firefox: Error: missing } after property list Source File: http://localhost/samples/php/crud/index.phpLine: 59, Column: 1 Source Code:container : 'gridbox', this is how it applied:
|
|
|
|
|
Logged
|
|
|
|
|
shaynl
|
 |
« Reply #5 on: May 13, 2010, 08:39:01 AM » |
|
hi, is there any news on how to apply the auto save? thanks 
|
|
|
|
|
Logged
|
|
|
|
|
PENDRAGON
|
 |
« Reply #6 on: May 17, 2010, 11:06:31 AM » |
|
You need to add a comma after the line. I have tried this myself and I get a JavaScript recursion error (as if it goes into an infinite save loop - oddly the record never gets saved at all though which one might expect even with the recursion issue).
(from your post) height: "200", //"100%", // 330, afterEdit : function(){ mygrid.save(); }, <---comma needed here container : 'gridbox',
|
|
|
|
|
Logged
|
|
|
|
|
shaynl
|
 |
« Reply #7 on: May 17, 2010, 01:21:08 PM » |
|
Thanks! Now it's working but I'm getting this recursion error when editing a cell: "out of memory at line:58" (it's this function line…). I'm wondering… is there any way to fix that?
|
|
|
|
|
Logged
|
|
|
|
|
PENDRAGON
|
 |
« Reply #8 on: May 17, 2010, 01:59:05 PM » |
|
I'd be very interested in the solution myself. I haven't been able to get this to work to auto save and it's the mygrid.save() function that is the problem. I've tried the following to see that the function is called and that the function itself isn't causing the loop.
afterEdit : function() { var recs = mygrid.getUpdatedRecords(); if(recs!=null&&recs.length>0){ //this checks to see if any field is updated alert('recs' + recs + '.'); //this shows an object reference for each updated field //mygrid.save(); //this line causes recursion error if uncommented } }
I have also tried to call onBlur and other events that don't seem to be called at all. The very odd thing is that it's not saving at all. If the .save() function worked it should save it even if it is creating a recursive loop.
|
|
|
|
|
Logged
|
|
|
|
|
PENDRAGON
|
 |
« Reply #9 on: May 17, 2010, 02:30:13 PM » |
|
As an experiment to get an Auto Save function to work, I put a hidden field in a form on the Web page outside of the grid to hold a value. I use this value to act as a toggle switch in order to stop the .save() function from looping (recursion).
Here's the form on my web page to store the toggle value: <form id='toggler' name='toggler'><input type='hidden' value='0' id='toggleval' name='toggleval'></form>
Then I used the following in my gridOption area: afterEdit : function() { var recs = mygrid.getUpdatedRecords(); var formval = document.getElementById('toggleval').value; if(recs!=null&&recs.length>0&&formval==0){ document.toggler.toggleval.value=1; mygrid.save(); mygrid.refresh(); document.toggler.toggleval.value=0; } } (remember to put a comma after the bracket at the end if there are more items after it. I put this as the last thing on mine.
Some explanation - first I check if there are any updated records since the 'afterEdit' event seems to trigger with or without any changes to the data in a cell (which is probably by design). I didn't want to save unchanged records to the database for obvious reasons. After I check that there is an update, I check the value of the toggle (starts out at Ø). As long as that value is Ø and just before calling that recursive .save() function I set the flag to 1. Then I execute the .save() followed by a .refresh(). This seems to stop the recursion (since the toggle doesn't equal Ø). After that I set the value of the hidden field back to Ø so that it's ready for the next update.
Seems to work fine for me. It's not a great workaround but I don't want to mess with the supplied javascript for the sigma grid itself.
Hope this is helpful until a better answer is posted.
-PEN
|
|
|
|
|
Logged
|
|
|
|
|
shaynl
|
 |
« Reply #10 on: May 18, 2010, 01:59:43 AM » |
|
Nice workaround! It's working fine for the update but there are some other problems: 1. No auto save when deleting row. 2. No auto save when adding new row. 3. Duplicate row bug: when start adding new row and then moving to update existing row (without clicking save), after the update, it save everything but duplicate the new row. Can we improve this workaround to handle those 3 things? Thanks 
|
|
|
|
|
Logged
|
|
|
|
|
PENDRAGON
|
 |
« Reply #11 on: May 18, 2010, 10:42:59 AM » |
|
In the instance I am working with, I don't have a need to auto save for delete or add so I didn't try to figure that out.
I would say that the afterEdit event is not firing in those two instances so the code isn't running. You would have to find out what events happen. Possibly change the Add function so that it actually creates a new record with blank or default data which would then just make it just another record you could edit. On the delete, maybe update the JavaScript to fire a save command directly after marking the item for deletion which should make it delete with one click.
I didn't even know there was a duplicate command that was native so I'll have to look at that.
If I get time I'll look into some of this but I doubt that will be very soon. I'm sure someone else has a better idea about these items.
|
|
|
|
|
Logged
|
|
|
|
|
shaynl
|
 |
« Reply #12 on: May 20, 2010, 04:02:06 AM » |
|
The auto save on adding is more important…the solution for that like u said will be saving an empty row when clicking add. .. I tried this but it's not working: Any clue why?
|
|
|
|
|
Logged
|
|
|
|
|