tabulator.js: list with valuelookup and custom ajax-get

61 Views Asked by At

I am trying to use a list inside a column at tabulator.js. The source of this list should be a custom ajax request.
As far as I understood, I must return a promise. But it doesn't work. The http-request is done, but I see in the dropdown only nonsense. Can someone give me a hint, please?

{title:"Name", field:"name", editor:"list", editorParams:{
    valuesLookup:function(cell, filterTerm){
          res =  $.ajax({
              url: "/api/v1/networks",
              type: "GET",
              contentType: "application/json; charset=utf-8",
              dataType: "json",
          });
          return res.promise();
    }
}},

If I use the implemented "valuesURL" it is working fine, but I can not use this later on.

1

There are 1 best solutions below

0
MatrixClient On

I found the following solution myself:

{title:"Name", field:"name1", editor:"list", editorParams:{
valuesLookup:function(cell, filterTerm){
  return new Promise(function(resolve, reject){
    $.ajax({
        url: "/api/v1/networks",
        success: function(data){
            resolve(data);
        },
        error: function(error){
            reject(error);
        },
    })
  })
}

}},