HandsonTableの検索結果フィルタ表示が意外と簡単に 実装できた。すばらしい。 こうして ---------------------------------- var searchField = document.getElementById("searchField"); var resultCount = document.getElementById("resultCount"); Handsontable.Dom.addEvent(searchField, 'keyup', function(event) { filter(('' + this.value).toLowerCase()); resultRow = hot.countRows()-1; //0スタートなので-1が必要 resultCount.innerText = "検索結果:" + resultRow.toString() + "件"; }); --------------------------- こう -------------------------------- function filter(search) { var row, r_len, data = myData, // Keeping the integretity of the original data array = []; for (row = 0, r_len = data.length; row < r_len; row++) { for(col = 0, c_len = data[row].length; col < c_len; col++) { if(('' + data[row][col]).toLowerCase().indexOf(search) > -1) { array.push(data[row]); break; } } } hot.loadData(array); } -------------------------------- I'm currently trying to add a search filter on a column in handsontable. I can use the callback of the search plugin to hide the rows with css but that breaks scrolling. The search plugin also seem...
HandsonTableの検索結果フィルタ表示が意外と簡単に 実装できた。すばらしい。 こうして ---------------------------------- var searchField...
=======================================
http://ift.tt/1abnmbU
December 20, 2016 at 04:13PM
=======================================
HandsonTableの検索結果フィルタ表示が意外と簡単に
実装できた。すばらしい。
こうして
----------------------------------
var searchField = document.getElementById("searchField");
var resultCount = document.getElementById("resultCount");
Handsontable.Dom.addEvent(searchField, 'keyup', function(event) {
filter(('' + this.value).toLowerCase());
resultRow = hot.countRows()-1; //0スタートなので-1が必要
resultCount.innerText = "検索結果:" + resultRow.toString() + "件";
});
---------------------------
こう
--------------------------------
function filter(search) {
var
row, r_len,
data = myData, // Keeping the integretity of the original data
array = [];
for (row = 0, r_len = data.length; row < r_len; row++) {
for(col = 0, c_len = data[row].length; col < c_len; col++) {
if(('' + data[row][col]).toLowerCase().indexOf(search) > -1) {
array.push(data[row]);
break;
}
}
}
hot.loadData(array);
}
--------------------------------
実装できた。すばらしい。
こうして
----------------------------------
var searchField = document.getElementById("searchField");
var resultCount = document.getElementById("resultCount");
Handsontable.Dom.addEvent(searchField, 'keyup', function(event) {
filter(('' + this.value).toLowerCase());
resultRow = hot.countRows()-1; //0スタートなので-1が必要
resultCount.innerText = "検索結果:" + resultRow.toString() + "件";
});
---------------------------
こう
--------------------------------
function filter(search) {
var
row, r_len,
data = myData, // Keeping the integretity of the original data
array = [];
for (row = 0, r_len = data.length; row < r_len; row++) {
for(col = 0, c_len = data[row].length; col < c_len; col++) {
if(('' + data[row][col]).toLowerCase().indexOf(search) > -1) {
array.push(data[row]);
break;
}
}
}
hot.loadData(array);
}
--------------------------------
http://ift.tt/1abnmbU
December 20, 2016 at 04:13PM
コメント
コメントを投稿