4

I'm using web2py to build a dynamic web UI to a MySQL backend, and I'm new to the web2py framework and web development in general.

What I'm looking for is a library or plug-in with the following features that is either built for or compatible with web2py.

1) Inline editing of records retrieved from a table (multiple records at a time, not just one at a time), with all changes being sent back to the database upon submission.

2) Drop-downs menus for the values of certain fields of those records; the values for the drop-downs will depend on the value of another field for that record.

3) Ability to create new records.

--

Below are few solutions that seem to come close to what I'm looking for. But everything that's ready-made seems to cost or requires that my project be open-source. [DOT]'s included to allow more than two links.

http://datatables.net/index - no inline editing without purchasing of plug-ins

http://wijmo.com/widgets/wijmo-complete/grid/ - grid only comes with licensed version of wijmo

http://trirand.com/blog/jqgrid/jqgrid.html - seems promising, but how do I send data back to the server using web2py? Also, how would I create drop-downs for certain fields?

http://dev.sencha.com/deploy/ext-4.0.0/examples/grid/cell-editing.html - this seems to be what i'm looking for, but i don't want to pay for the licensing.

--

My preference is to use something that's already been built. However, many people seem to think that writing my own UI is the best way.

Any suggestions on a good path forward?

Eric S.
  • 320
  • 2
  • 11

2 Answers2

0

Having you seen the following lists of plugins, http://dev.s-cubism.com/web2py_plugins They do most of what you are looking for.

samaras
  • 235
  • 4
  • 20
0

There are couple of solutions: https://groups.google.com/forum/#!topic/web2py/2AvvmszNrgA

Steps: Download jeditable, Install in the static/js folder. Add code to template:

<script src="{{=URL('static','js/jquery.jeditable.js')}}"></script>

Model:

db.define_table('dogs',
Field('dog_name','string'))

Controller:

def populate():
    db.dogs.truncate()
    db.fleas.truncate()

    db.dogs.insert(dog_name='dagwood')
    db.dogs.insert(dog_name='daisy')

def dogs():
    db.dogs.dog_name.represent = lambda value, row: DIV(value if value else '-',_class='dog_name', _id=str(row.id)+'.dog_name')
    g = SQLFORM.grid(db.dogs, searchable=False, csv=False, user_signature=False)
    return dict(form = g)

def upd_dog_name():
    id,column = request.post_vars.id.split('.')
    value = request.post_vars.value
    db(db.dogs.id == id).update(**{column:value})
    return value

View:

{{extend 'layout.html'}}

<script>
jQuery(document).ready(function(){
    jQuery('.dog_name').editable("{{=URL('dogs', 'upd_dog_name')}}",{                   
        tooltip: "Click to edit, enter to save",
 indicator : 'updating',
 });})
</script>


<div id='dogs'>
    {{=form}}
</div>

Another way (with less programming) is to use this web2py slice: http://www.web2pyslices.com/slice/show/1714/jqgrid-viewing-and-updating-data

acidjunk
  • 1,751
  • 18
  • 24