Hi, I am trying to get these two to work together. I really need to be
editing many fields within a table, and cannot impose the pain of
leaving to another screen to the users to change some text fields and
then coming back.

So, I have set up DataTables + jeditable (I also tried to do this with
the WebGrid from Mr.Freeze but also with no luck). Anyway, the core of
it all is just these two functions:

def fill_up_table():
    table = db(db.direccionesgrupo.id>0).select(limitby = (0,10))
    f_table = TABLE(THEAD(TR([TH(val) for val in table[0]])),
        *[TR(*[TD(item, _id=key) for key,item in rows.iteritems()],
_id=rows.id) for rows in table],
        _id="table_id",_class="display")
    return dict(message = f_table)

def update_field():
    if request.vars:
      pdb.set_trace() ############################## Breakpoint
##############################
      if request.vars['id'] == 'NotasDireccion':
        db.direccionesgrupo[request.vars['row_id']]=dict
( NotasDireccion = request.vars['value'])
    else:
      pass

Along with this setup for the datatables + jeditable, that calls for
update_field whenever there is an update to do:
                <script type="text/javascript" charset="utf-8">
                        var oTable;

                        $(document).ready(function() {
                                /* Apply the jEditable handlers to the table */
                                $('#table_id tbody td').editable( 
'/eibport/default/update_field',
{
                                        "callback": function( sValue, y ) {
                                                var aPos = 
oTable.fnGetPosition( this );
                                                oTable.fnUpdate( sValue, 
aPos[0], aPos[1] );
                                        },
                                        "submitdata": function ( value, 
settings ) {
                                                return { "row_id": 
this.parentNode.getAttribute('id') };
                                        },
                                        "height": "14px"
                                } );

                                /* Init DataTables */
                                oTable = $('#table_id').dataTable();
                        } );

                </script>

Everything seems to be working ok, except for 2 things:

1.- Table loading takes too long: This started happening when I
inserted the inner itteration of rows.iteritems() to be able to insert
the TD id to know the column I am editing.  (Before that, having it
like this:
TABLE(*[TR(*rows) for rows in table])
it went pretty fast. So even though to me it looks ok, there must be
something I am missing that I am screwing up.
2.- All the data gets sent correctly to the update function, but I
dont get data to be updated. (And this must be clearly a most basic
concept of web programming that I am completelly missing).

Anyway, any other alternative to being able to edit several fields in
a table straight in the table, will be wellcome.

I'll post a slice as soon as i have it working one way or another.

Cheers,
Benigno.

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to