plugin for handsontable

80 views
Skip to first unread message

Pablo Angulo

unread,
Jul 29, 2015, 12:59:27 PM7/29/15
to web...@googlegroups.com
I have packaged a plugin with one possible use of the great library handsontable:

http://www.web2pyslices.com/slice/show/2042/handsontable-plugin-for-a-spreadsheet

You may comment on the plugin as you want, but I specifically want to ask if you find the following trick acceptable (or improvable):

The Handsontable plugin is used to load client side a potentially very big table, and the data is stored by handsontable. I decided to suscribe to the 
afterValidate event of the Handsontable object:

        afterValidate:function(isValid,value,row,prop,source){
            if(isValid){
                override[[rowids[row], prop]] = value;
            }
        }

and record only the values that the user updates.
Close to the div that holds the table there is a form consisting of a submit button and hidden field.
Then before the form is submitted, I stringify the object with all the changes, and attach it to the hidden form field:

    $('#submit').on('click', function(){
        $('#override').val(JSON.stringify(override));
    });

Back in web2py, I recover the changes by the user in this way:

        import json as json_parser
        override = json_parser.loads(request_vars.override)

Any comments would be appreciated.

Massimo Di Pierro

unread,
Jul 30, 2015, 12:34:34 AM7/30/15
to web2py-users, pa...@cancamusa.net, pa...@cancamusa.net
Fantastic. I a big fun of handontable.

Tim Richardson

unread,
Aug 3, 2015, 6:11:13 AM8/3/15
to web2py-users
Lazy question ... how easy is it to theme like web2py widgets / menus etc?

pa...@cancamusa.net

unread,
Aug 3, 2015, 8:52:35 AM8/3/15
to web2py-users
El lunes, 3 de agosto de 2015, 12:11:13 (UTC+2), Tim Richardson escribió:
Lazy question ... how easy is it to theme like web2py widgets / menus etc?

The plugin just adds a big handsontable with two buttons. I used the handsontable-bootstrap compatibility, and that's about all I know about theming, I'm afraid.
Reply all
Reply to author
Forward
0 new messages