admin管理员组文章数量:1380991
What is the best way to upload data entered by user in jQuery Handsontable back to Server to be saved into database?
The existing onChange
callback seems to be very verbose to save input data using AJAX especially if user insert new data row above existing one.
Looking for functionality to upload input data after plete the editing using Handsontable or jQuery
Here is the full code using jQuery to loop the input data and dump into text box in JSON format then submit to server. This process look ugly. looking for a cleaner way..
$('#btnGo').click(function() {
var rowList = new Array();
$("table tr").each(function() {
var colList = new Array();
$("td", this).each(function() {
colList.push($(this).text());
});
rowList.push(colList);
});
$('#simple').val(JSON.stringify(rowList));
console.log(rowList);
});
What is the best way to upload data entered by user in jQuery Handsontable back to Server to be saved into database?
The existing onChange
callback seems to be very verbose to save input data using AJAX especially if user insert new data row above existing one.
Looking for functionality to upload input data after plete the editing using Handsontable or jQuery
Here is the full code using jQuery to loop the input data and dump into text box in JSON format then submit to server. This process look ugly. looking for a cleaner way..
$('#btnGo').click(function() {
var rowList = new Array();
$("table tr").each(function() {
var colList = new Array();
$("td", this).each(function() {
colList.push($(this).text());
});
rowList.push(colList);
});
$('#simple').val(JSON.stringify(rowList));
console.log(rowList);
});
Share
Improve this question
edited Jun 27, 2012 at 15:28
i.am.michiel
10.4k7 gold badges54 silver badges86 bronze badges
asked May 31, 2012 at 10:39
AzizSMAzizSM
6,3094 gold badges44 silver badges54 bronze badges
0
1 Answer
Reset to default 7There is a build in method for getting the whole array of table data: .handsontable("getData")
You can use it like this:
$('#btnGo').click(function() {
var rowList = $("#example9grid").handsontable("getData");
$('#simple').val(JSON.stringify(rowList));
console.log(rowList);
});
Working example: http://jsfiddle/warpech/bwv2s/20/
本文标签: javascriptUpload jQuery Handsontable inputStack Overflow
版权声明:本文标题:javascript - Upload jQuery Handsontable input - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744493507a2608878.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论