I am using Tablulator 4.1, which is a pure javascript library for tables. One column of my table provides a drop down list of values. I had this working by calling the function directly from editorParams:, but I got a warning that this method is being depreciated and to use the following method.
I am having trouble adapting my method to the new method. Initially when I click on the cell, nothing happens, but if I click another cell, the list of values appears as it should and then every subsequent cell I click. . I think I must be close, but do not understand why it is not populating the list on first click.
JavaScript:
{title:"Room", field:"room", editor:"select", editorParams:{
values:function(cell){
//lookup values from data source
return values;
}}},
I am having trouble adapting my method to the new method. Initially when I click on the cell, nothing happens, but if I click another cell, the list of values appears as it should and then every subsequent cell I click. . I think I must be close, but do not understand why it is not populating the list on first click.
JavaScript:
{title:"Room", field:"room", editor:"select", editorParams:{
values:function(cell){
return getroomlist();}
}},
function getroomlist() {
var file = "../textfiles/room_array.txt";
var rawFile = new XMLHttpRequest();
rawFile.open("GET", file, true);
rawFile.onreadystatechange = function ()
{
if(rawFile.readyState === 4)
{
if(rawFile.status === 200 || rawFile.status == 0)
{
var data = JSON.parse(rawFile.responseText);
}
//roomlist = {};
window.roomlist = data.map(function(e)
{
return e.room;
});
}
}
rawFile.send(null);
return window.roomlist;
}