|Example of web2py integration with an AJAX grid (preferably jquery based) which updates backend db ?||Tim Richardson||9/2/13 5:10 PM|
Can anyone provide tutorial/example of a web2py implementation of an AJAX grid which updates records? web2py slices has jqgrid in read only mode, (although the example doesn't work out of the box anymore).
My learning curve is working out good ways to send update requests back to the server, however pretty sure this wheel is already invented.
|Re: Example of web2py integration with an AJAX grid (preferably jquery based) which updates backend db ?||Anthony||9/2/13 5:20 PM|
|Re: Example of web2py integration with an AJAX grid (preferably jquery based) which updates backend db ?||Niphlod||9/2/13 11:52 PM|
totally unrelated note: did you try simply loading a grid via ajax ? if your db isn't slow, from the user perspective it's pretty fast.
|Re: Example of web2py integration with an AJAX grid (preferably jquery based) which updates backend db ?||Tim Richardson||9/3/13 12:44 AM|
I don't know how to use SQLFORM.grids for inline editing, only via the edit button.
|Niphlod||9/3/13 2:28 AM|
it's one of my long-end goals to provide an inline-editing-capable sqlform grid right in web2py source. As of right now, you're forced to choose a grid and reinvent the wheel....other project made for web2py I think need a tiddle bit of refactoring, but are a good and solid starting point.
|Simon Ashley||9/3/13 6:06 PM|
jeditable is reasonably easy to work with for a cell at a time editing, and works with SQLFORM.grids. Have played around with kendoui grids and their editing is some of the nicest. Could put together some crude examples.
|Tim Richardson||9/3/13 7:46 PM|
Hadn't heard of jeditable ... 'works with SQLFORM.grids' sounds good ... crude examples or pointers would be good, particularly around communicating updates (this is the big unknown for me).
|Simon Ashley||10/5/13 7:35 PM|
Install in the static/js folder.
Include in layout.html i.e.
|Tim Richardson||9/6/13 5:31 AM|
Thanks, that is really cool (jeditable) and so easy to integrate with existing web2py code. I wonder if it works when the form is LOADed via a component ...
I'm going to play a bit more, and then add it to web2py slices with attribution to you.
|Simon Ashley||9/6/13 4:56 PM|
Thanks, enjoy. Most of our forms are loaded and still works fine.
|tomt||9/8/13 5:51 PM|
I wanted to thank you for the answer you posted.
As a casual user of web2py, I would have never figured this out
on my own, but your clear example showing db, controller and view
made it easy for me to understand and to implement.
It would be great if the experienced users of web2py would
contribute similar small examples. I believe that would be
one way to help make web2py more popular.
ps. I had to modify the following to get update to work:
|Tim Richardson||9/16/13 10:49 PM|
I persevered with jqGrid and added a new slice on web2py slices, which describes how to get a nice looking jqGrid working for editing records.
|Py Dev||10/5/13 4:25 AM|
thank you for sharing the idea and the code!
When I tried the code, I had some errors:
First the second line in populate does not fit to the model: #db.fleas.truncate() #AttributeError: 'DAL' object has no attribute 'fleas'
Second, the "dogs" view shows a web2py grid, I can edit it normally. It seems that the inline-edit code "upd_dog_name" is never invoked?
The idea is wonderful, even better when the code would work :-)
Can you please check this code? Thank you for your help!
|Tim Richardson||10/5/13 6:16 AM|
|Greg Sier||10/5/13 6:55 PM|
Just remark out/ delete the truncate fleas line.
If the 'upd_dog_name' function is not called, check installation and calling of jeditable
|Py Dev||10/7/13 6:44 AM|
thanks for your tip with the jQuery Grid code.
My question referred to the code from "Simon Ashley" how to use "jeditable", see best marked answer...
This code is not on web2pyslices
|Py Dev||10/7/13 6:51 AM|
thanks for your quick answer! There is some progess, an other error message: :-)
Traceback (most recent call last):
File "/Users/myname/PycharmProjects/DataBaseExamples/web2py/gluon/restricted.py", line 217, in restricted
exec ccode in environment
File "/Users/myname/PycharmProjects/DataBaseExamples/web2py/gluon/globals.py", line 371, in <lambda>
self._caller = lambda f: f()
line 14, in upd_dog_name
id,column = request.post_vars.id.split('.') #'NoneType' object has no attribute 'split'
AttributeError: 'NoneType' object has no attribute 'split'
Did you take the code from a working example?
Thanks for your help!
|Py Dev||10/7/13 7:50 AM|
I just found the problem:
has to be inserted after(!)
which adds jquery.js
Changing that, first my inline changes were reverted, but when I adapted the location
in the line
to my location of „upd_dog_name“ now it works perfect!
And this inline-editing is very useful too :-)
This should be integrated into web2py and/or the quick examples!
Do you have more examples of this kind? :-)
Excellent! Perfect! 10 of 10 stars! Thanks a lot!
|Re: [web2py] Re: Example of web2py integration with an AJAX grid (preferably jquery based) which updates backend db ?||Adnan Smajlovic||10/7/13 10:09 AM|
Thank you for this. Very helpful, and just implemented it in one of my grids! Also checked Kendoui. Looks very nice.
|Greg Sier||10/7/13 3:46 PM|
w2p is a great framework with many bells and whistles.
Examples/ defaults are full of them.
One of the issue when you're learning the framework, you need to take baby steps, and study them one at a time.
(particularly if, like myself, you are new to python, js, CSS3, Bootstrap, etc, etc and feel, at times, you dumber than dogs...)
The example posted was stripped from a larger system, sanitised and tested.
Unfortunately, I didn't strip out a few (i.e truncate) testing lines.
I find simple, one or 2 line code snippets, great (the smaller the better).
Its easier to join/ merge later.
Similar comments go for troubleshooting and posting issues.
Its always easier for others if you reduce code just to key elements, to illustrate the point.
Slices are good, but they are a bit static/ non interactive.
I'm now wondering how difficult it would be to clone and host a jsfiddle type sandbox in w2p, whereby we could post, share, test and modify code snippets within the community?
|Mark Billion||3/7/14 6:41 AM|
I am sure I am an idiot, but when I hit enter to update (ie, petunia to petuniatest), it reverts back to the same old dog name (petunia).
id,column = request.post_vars.id.split('.')
value = request.post_vars.value
|Greg Sier||3/7/14 2:32 PM|
Try the simple things first (good exercise in debugging):