【发布时间】:2016-01-02 09:43:49
【问题描述】:
我尝试使用 Handsontable 插件并希望使用 ajax 对表格上的数据进行排序。
当我使用columnSorting: true 时,只对视图进行排序,我更新它出错的索引行。
有人知道如何从 php 中对数据进行排序,然后在表格上排序后显示数据结果吗?
$container.handsontable({
colHeaders: header(),//["Title", "Description", "Comments"],
data : data(),
//startRows: 3,
columnSorting: true,
startCols: 20,
rowHeaders: true,
colHeaders: true,
minSpareRows: 1,
contextMenu: true,
copyRowsLimit: 100000,
beforeChange: function (change, source) {
if (source === 'loadData') {
return; //don't save this change
}
if ($('input[name=autosave]').is(':checked')) {
$("#dataconsole").html("<p>Please wait ...</p>").hide().fadeIn("slow");
clearTimeout(autosaveNotification);
$.ajax({
url: "../php/save_auto.php?cmid=<?php echo $com_id;?>",
type: "POST",
data: {"changes": change}, //contains changed cells' data
success: function (data) {
$("#dataconsole").text('Autosaved (' + change.length + ' cell' + (change.length > 1 ? 's' : '') + ')');
if(source !== 'program'){
// reset current cell
$( "td:contains('=')").text(data);
}
}//complete
});
}//checked
}//change
});
【问题讨论】:
标签: javascript php jquery ajax handsontable