私が使っているhandsontableについてまとめます
4178 ワード
// var haedgen = [" ", " ", " *", " - コード *"];
// ,
var data = [["", "", "", ""]];
//
var backRenderer = function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
td.style.backgroundColor = '#ADADAD';
};
// date text select
var columngen = [{ type: 'date', dateFormat: 'YYYY/MM/DD' },//
{ type: 'text' },//
{ editor: 'select', selectOptions: [" ", " "]},//
{ type: 'text', allowEmpty: true, DefaultValue: false}// - コード
]
$(function () {
//
var $container = $("#datatable");
hot1 = $container.handsontable({
data: data,
colHeaders: haedgen,
minSpareRows: 1,
width: "100%",
height: 500,
columns: columngen,
rowHeaders: true,
//manualColumnFreeze: true,
contextMenu: true,
// - コード ,, ,, 。。
afterChange: function (changes, source) {
if (source == "loadData") {
}
else if (source == "edit" || source == "paste" || source == "autofill") {
for (var i = 0; i < changes.length; i++) {
// コード
if (changes[i][1] == 3) {
var AccountName = AccountSelect(changes[i][3]);
var $container = $("#datatable");
$container.handsontable('setDataAtCell', changes[i][0], 4, AccountName);
}
//
if (changes[i][1] == 6) {
var VenEmpName = VenEmpSelect(changes[i][3]);
var $container = $("#datatable");
$container.handsontable('setDataAtCell', changes[i][0], 7, VenEmpName);
}
//
if (changes[i][1] == 10) {
var OrgName = OrgSelect(changes[i][3]);
var $container = $("#datatable");
$container.handsontable('setDataAtCell', changes[i][0], 11, OrgName);
}
}
}
},
});
handsontable
var handsontable = $container.data('handsontable');
var data = handsontable.getData();
ajax controller
$.ajax({
type: "post",
url: "/BatchMain/Select",
dataType: "json",
data: { "data": json, "selectvalue": selectjson },
success: function (jsonResult) {
if (jsonResult == "0") {
alert("データ しました。");
return 0;
}
}
});
$container.handsontable('alter', 'remove_row', i);
http://past.handsontable.com/demo/contextmenu.html
https://docs.handsontable.com/0.25.0/tutorial-data-sources.html?_ga=1.120691531.215382175.1465181891