Pablo Angulo
2015-07-29 16:59:01 UTC
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.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.