如何刷新引导表数据 [英] How to refresh bootstrap table data

查看:88
本文介绍了如何刷新引导表数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

推荐答案

您遵循的方法是正确的,除了在mydataAction

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

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

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

> 工作小提琴

更新

使用load函数代替append

> 检查此内容

这篇关于如何刷新引导表数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆