jQuery 如何刷新引导表数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27915296/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:28:45  来源:igfitidea点击:

How to refresh bootstrap table data

jquerytwitter-bootstrap

提问by Noono

I have one bootstrap table with the following code.

我有一个带有以下代码的引导表。

<table id="tblPendingRequests" data-height="300">
   <thead>
     <tr>
         <th data-field="Version">Version</th>
         <th data-field="Env">Env</th>
         <th data-field="Release">Release</th>
         <th data-field="CreatedBy">Created By</th>
         <th data-field="Action">Action</th>
     </tr>
  </thead>
</table>

added below references also.

还添加了以下参考资料。

function loadData(){
    $(function () {
        $('#tblPendingRequests').bootstrapTable({});
    });
}

Then I am loading some data to this table with the following lines of code

然后我使用以下代码行将一些数据加载到该表中

var mydata = { 
    "Version": data[index].DeploymentName, "Env": data[index].EnvName, 
    "Release":data[index].ReleaseName, "CreatedBy": data[index].UpdatedBy  
    "Action": ActionButton 
};          
testData.push(mydata);
updateData(testData);
function updateData(myData) {
    $('#tblPendingRequests').bootstrapTable("append", myData);
}

It is diplaying the data properly. I have one project dropdown on the page. Onchange of the project name i want to populate this table with fresh data. It is not happening. It is appending data to existing table data which i dont want. How to refresh the table and load new data in the table.

它正在正确显示数据。我在页面上有一个项目下拉列表。更改项目名称时,我想用新数据填充此表。它没有发生。它将数据附加到我不想要的现有表数据。如何刷新表并在表中加载新数据。

回答by Cerlin

The method you have followed is correct except, in mydataa comma is missing before Action

您遵循的方法是正确的,只是mydata之前缺少逗号Action

Also make sure that the values like data[index].DeploymentNameare existing.

还要确保像这样的值data[index].DeploymentName存在。

Working Fiddle

工作小提琴

UPDATE

更新

Use loadfunction instead of append

使用load函数代替append

CHECK THIS

检查这个