Cell Popup with data from custom data source

Viewed 11

I am trying to make tabulator to show clickPopup with data that comes with additional http-request. Here is the definition of certain column, which calls cellPopupFormatterVV function:

{title:"WSCReportVolumes", field:"WSCReportVolumes.ErrorShort", 
              mutator:mutatorNoData,
              clickPopup:cellPopupFormatterVV
},

Here is function itself:

  var cellPopupFormatterVV = function(e, cell, onRendered){
  var cellContent = cell.getData();
  var data = handlerCellPopup();
  var container = document.createElement("div");
  
  var contents = "<strong style='font-size:1.2em;'>Status details</strong><br/><ul style='padding:0;  margin-top:10px; margin-bottom:0;'>";
  contents += "<li><strong>Error:</strong> " + data.ErrorShort + "</li>";
  contents += "<li><strong>Error Code:</strong> " + data.ErrorCode + "</li>";
  contents += "<li><strong>Error Description:</strong> " + data.ErrorLong + "</li>";
  contents += "<li><strong>Failed Check:</strong> " + data.FunctionName + "</li>";
  contents += "<li><strong>Result:</strong> " + data.ShortMsg + "</li>";
  contents += "</ul>";

  container.innerHTML = contents;
  return container;
};

I'm trying to get data through function handlerCellPopup() which is in separate file "controller_ajax.js":

<script type="text/javascript" src="controller_ajax.js"></script>

The function itself:

  function handlerCellPopup() {
    const xhttp = new XMLHttpRequest();
    xhttp.onload = function() {
        let Response = xhttp.response;
        return (Response);
      };
    xhttp.open("GET", "http://localhost:8003/ajax?cellPopup=rov_WSCReportVolumes_Last&computerName=ALAV706", true);
    xhttp.responseType = 'json';
    xhttp.send();
  }

When I do request through browser, it returns exactly what I expect:

[{"ErrorLong":"Free disk space is low","ExecCode":1,"ErrorShort":"Warning","FunctionName":"Check-IsVolumeLowSpace","ErrorCode":201,"ShortMsg":"C:\\"}]

But if I try to click cell in tabulator no popup is shown. I think there is a problem with handlerCellPopup() but no idea how should I change function. Please, help.

0 Answers
Related