Last active
July 28, 2023 03:21
-
-
Save scillidan/2db8cffcf55144e4e1a8f1892baf3a47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var minMaxFilterEditor = function (cell, onRendered, success, cancel, editorParams) { | |
var end; | |
var container = document.createElement("span"); | |
var start = document.createElement("input"); | |
start.setAttribute("type", "number"); | |
start.setAttribute("placeholder", "Min"); | |
start.setAttribute("min", 0); | |
start.setAttribute("max", 100); | |
start.style.padding = "4px"; | |
start.style.width = "50%"; | |
start.style.boxSizing = "border-box"; | |
start.value = cell.getValue(); | |
function buildValues() { | |
success({ | |
start: start.value, | |
end: end.value, | |
}); | |
} | |
function keypress(e) { | |
if (e.keyCode == 13) { | |
buildValues(); | |
} | |
if (e.keyCode == 27) { | |
cancel(); | |
} | |
} | |
end = start.cloneNode(); | |
end.setAttribute("placeholder", "Max"); | |
start.addEventListener("change", buildValues); | |
start.addEventListener("blur", buildValues); | |
start.addEventListener("keydown", keypress); | |
end.addEventListener("change", buildValues); | |
end.addEventListener("blur", buildValues); | |
end.addEventListener("keydown", keypress); | |
container.appendChild(start); | |
container.appendChild(end); | |
return container; | |
}; | |
function minMaxFilterFunction(headerValue, rowValue, rowData, filterParams) { | |
if (rowValue) { | |
if (headerValue.start != "") { | |
if (headerValue.end != "") { | |
return rowValue >= headerValue.start && rowValue <= headerValue.end; | |
} else { | |
return rowValue >= headerValue.start; | |
} | |
} else { | |
if (headerValue.end != "") { | |
return rowValue <= headerValue.end; | |
} | |
} | |
} | |
return true; | |
} | |
var table = [ | |
{:""}, | |
{:"", _children:[ | |
{:""}, | |
]}, | |
]; | |
var table = new Tabulator("#tabulator", { | |
height:"600px", | |
layout:"fitColumns", | |
headerVisible:false, | |
// responsiveLayout:"hide", | |
// groupBy: "gp", | |
// groupStartOpen:true, | |
// selectable:true, | |
data:table, | |
dataTree:true, | |
dataTreeFilter:false, | |
dataTreeSort:false, | |
dataTreeStartExpanded:false, | |
columns:[ | |
// {title:"", field:"", formatter:"html", headerFilter:"input"}, | |
// {title:"", field:"", formatter:"textarea", headerFilter:"input"}, | |
// {title:"", field:"", formatter:"progress", formatterParams:{ | |
// min:0, | |
// max:10, | |
// color:["green", "orange", "red"], | |
// legendColor:"#000000", | |
// legendAlign:"center", | |
// }} | |
], | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment