Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

jquery - How to refresh bootstrap table data

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

Working Fiddle

UPDATE

Use load function instead of append

CHECK THIS


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...