动态创建的Tabulator表列大小不正确

如何解决动态创建的Tabulator表列大小不正确

我正在尝试使用制表符(4.4.3)使用JSON数据动态生成表,但遇到了一些麻烦。 因此,表是在一个循环中创建的,因此,如果循环中只有一个表,则REDRAW函数的作用就像一个超级按钮,但是当有多个表时,重绘函数就会遇到麻烦。 表格列的大小调整不正确。

我们使用了引导程序选项卡,并且在其中一个选项卡中,我们需要动态地创建多个表作为for循环中的for迭代中的代码。 但是列的大小不能正确调整,使用选项卡的onclick函数放置的重绘函数只是制表符表之一。 对于EG:如果我有多个表,则必须单击已经处于活动状态的同一选项卡才能再次启用onclick功能,以便其他表重绘自身。

我希望您能帮助我解决此问题。

下面是供参考的代码

<body>
  <ul class="nav nav-tabs">
    <li><a data-toggle="tab" onclick="tabulatorTechnicalChecklistTableShow();" href="#technicalchecklist"><label class="inline fWeight" th:text="#{label.Checklist}"></label></a>
    </li>
  </ul>
  <div class="tab-content">
    <div id="technicalchecklist" class="tab-pane fade" style="display: none;">
      <div class="row">
        <div class="col-xl-12 col-md-12 mb-12">
          <div id="technicalChecklistTable"></div>
          <div id="techChecklistGroupingExample">
            <div id="addTechChecklistDivId"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>
<script>
    function tabulatorTechnicalChecklistTableShow(){
       for(var i = 0; i < techChecklistGroupID; i++){
         var tempTechnicalChecklistTable = window["technicalChecklistTable_"+i];
         setTimeout(function(){tempTechnicalChecklistTable.redraw(true); },200);
         tempTechnicalChecklistTable.redraw(true);
       }
    }
</script>

ERROR SCREENSHOT

function getTechChecklistGroupedData() {
  var techChecklistFirstTabulator = technicalChecklistTable;
  for (var i = 0; i < techChecklistGroupID; i++) {
    $("#techChecklistGroupingExample").each(function() {
      var titleKey = $('#addTechChecklistTitleID_' + i).attr('name');
      var titleValue = $('#addTechChecklistTitleID_' + i).val();
      if (titleKey != undefined && titleValue != undefined) {
        var tempData = window["technicalChecklistTable_" + i].getData();
        if (i == 0) {
          techChecklistFirstTabulator.clearData();
        }
        for (var j in tempData) {
          tempData[j]["groupName"] = titleValue;
          if (tempData[j]["rfxChecklistGroupId"] == "0" || tempData[j]["rfxChecklistGroupId"] == undefined) {
            tempData[j]["rfxChecklistGroupId"] = "0";
          }
        }
        techChecklistFirstTabulator.addData(tempData);
        alert("actual looks like:" + JSON.stringify(techChecklistFirstTabulator.getData()));
      }
    });
  }
  alert("actual looks like:" + JSON.stringify(techChecklistFirstTabulator.getData()));
  technicalChecklistTable = techChecklistFirstTabulator;
}

function createTechChecklistDiv() {
  var markup = "";
  if (techChecklistGroupID == 0) {
    markup = "<div class='card mb-4'>" +
      "<div class='card-header' style='padding: 0.75rem 1.25rem;'>" +
      "<input type='text' id='addTechChecklistTitleID_" + techChecklistGroupID + "' name='addTechChecklistTitleID_" + techChecklistGroupID + "' class='form-control' onkeyup='validateSpecialCharsJSON(addTechChecklistTitleID_" + techChecklistGroupID + ");' placeholder='Title' style='width: 40%;display: inline-block;'>" +
      "<div id='addTechChecklistNewRowDiv_" + techChecklistGroupID + "'>" +
      "<input type='button' class='btn btn-info btnAlign' value='Add Criteria' onclick='addTabulatorRow(technicalChecklistTable_" + techChecklistGroupID + ");' />" +
      "</div>" +
      "</div>" +
      "<div id='addTechChecklistID_" + techChecklistGroupID + "'></div>" +
      "</div>";
  } else {
    markup = "<div class='card mb-4'>" +
      "<div class='card-header' style='padding: 0.75rem 1.25rem;'>" +
      "<input type='text' id='addTechChecklistTitleID_" + techChecklistGroupID + "' name='addTechChecklistTitleID_" + techChecklistGroupID + "' class='form-control' onkeyup='validateSpecialCharsJSON(addTechChecklistTitleID_" + techChecklistGroupID + ");' placeholder='Title' style='width: 40%;display: inline-block;'>" +
      "<i class='fa fa-close red' id='closeTechChecklistGroup_" + techChecklistGroupID + "' onclick='deleteCloneNode(this);' ></i>" +
      "<div id='addTechChecklistNewRowDiv_" + techChecklistGroupID + "'>" +
      "<input type='button' class='btn btn-info btnAlign' value='Add Criteria' onclick='addTabulatorRow(technicalChecklistTable_" + techChecklistGroupID + ");' />" +
      "</div>" +
      "</div>" +
      "<div id='addTechChecklistID_" + techChecklistGroupID + "'></div>" +
      "</div>";
  }
  $("#addTechChecklistDivId").append(markup);
}

function createTechChecklistGroupTabulator(jsonData) {
  window["technicalChecklistTable_" + techChecklistGroupID] = new Tabulator("#addTechChecklistID_" + techChecklistGroupID,{
    height: 380,data: jsonData,layout: "fitColumns",clipboard: true,clipboardcopyConfig: {
      columncalcs: false,},clipboardPasteAction: "replace",columns: [{
        title: "#",field: "num",formatter: "rownum",width: 5,headerSort: false,clipboard: false
      },{
        title: "Technical Checklist Id",field: "rfxChecklistId",visible: false
      },{
        title: "Rfx Header Id",field: "rfxHeaderId",{
        title: "Checklist",field: "questionnaire",widthGrow: 1,formatter: textAreaFormatter,bottomCalcFormatter: cellWithtextformatter,bottomCalcFormatterParams: "Total Weightage:"
      },{
        title: "Weightage(%)",field: "weightage",widthGrow: 0.2,bottomCalc: "sum",formatter: textfieldRangeFormatter,formatterParams: {
          validations: "numeric",columnName: "Weightage"
        }
      },{
        title: "",field: "cross",formatter: "buttonCross",width: 1,cellClick: function(e,cell) {
          var ROW = cell.getRow();
          ROW.delete();
        }
      },{
        title: "Group Name",field: "groupName",{
        title: "Rfx Technical Checklist Group Id",field: "rfxTechnicalChecklistGroupId",],});
}

function createTechChecklistGroupNonEditableTabulator(jsonData) {
  if (document.getElementsByName('rfxStatusId')[0].value == '2' ||
    document.getElementsByName('rfxStatusId')[0].value == '3') {
    window["technicalChecklistTable_" + techChecklistGroupID] = new Tabulator("#addTechChecklistID_" + techChecklistGroupID,{
      data: jsonData,placeholder: "Checklist not available",columns: [{
          title: "#",headerSort: false
        },{
          title: "Technical Checklist Id",visible: false
        },{
          title: "Rfx Header Id",{
          title: "Checklist",formatter: "textarea",bottomCalcFormatterParams: "Total Weightage:"
        },{
          title: "Weightage(%)",align: "left",});
  } else {
    window["technicalChecklistTable_" + techChecklistGroupID] = new Tabulator("#addTechChecklistID_" + techChecklistGroupID,{
      height: 380,columns: [{
          title: "Checklist",frozen: true
        },{
          title: "suppliers count",field: "supplierCount",index: "rfxChecklistId",rowFormatter: function(row) {
        var rowIndex = row.getIndex();
        if (rowIndex == "") {
          row.getElement().style.backgroundColor = "#afe1eb";
          row.getElement().classList.add("tabulator-header");
        }
      }
    });
  }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?