I am trying to display json data in bootstrap model table. with ajax call I am puling the data from database and my controller returns the data in json format. I tried to populate the json data into my model table. I dont know whats wrong. Can any body help me in this.
My model table
<div class="modal fade" id="modalTable" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
</div>
<div class="modal-body">
<table id="popupTable" class="table-nonfluid" data-toggle="table" data-height="450" width="450">
<thead>
<tr>
<th class="col-xs-1" data-field="countryCode">Country Code</th>
<th class="col-xs-1" data-field="Number"> Number</th>
<th class="col-xs-2" data-field="errorMessage">Error Message</th>
<th class="col-xs-1" data-field="countryCode">Country Code</th>
<th class="col-xs-6" data-field="jobId"> job Id</th>
<th class="col-xs-2" data-field="organizationName">Organization Name</th>
</tr>
</thead>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
When I click on the number I should show me another table that is a popup. I have given the popup code on top.
This is the code when I click on numbers 121,2,72. it calls
{
data : "numbers",
render : function(data,type, row) {
var failureRespons=data.split("|");
if(failureRespons[1]=='0')
{
return failureRespons[1];
}
else
{
return '<a href="#" onclick="showFailureJobs('+failureRespons[0]+','+failureRespons[1]+')" data-toggle="modal" data-target="#modalTable"><span class="text-primary">'+failureRespons[1]+'</span></a>'
}
}
}
Ajax call
function showFailureJobs(jobId,jobCount)
{
$.ajax({
type : "GET",
url : url bla bla,
data : '',
dataType : "json",
contentType: "application/json",
crossDomain:true,
success : function(data) {
$('#modalTable').on('shown', function() {
$('#popupTable').bootstrapTable({
columns: [{
field: 'countryCode',
title: 'Country Code'
}, {
field: 'Number',
title: 'Number'
}, {
field: 'errorMessage',
title: 'Error Message'
}, {
field: 'jobId',
title: 'Job Id'
},{
field: 'organizationName',
title: 'Organization Name'
},
],
data:data
});
})
//Even I harcoded the data like this but I am not getting the data in table
$(document).ready(function() {
$('#modalTable').on('shown', function() {
$('#popupTable').bootstrapTable({
data: [
{
"countryCode" : "1",
"Number" : "NL",
"errorMessage" : "msg.",
"jobId" : "1",
"organizationName" : "us"
},
{
"countryCode" : "2",
"Number" : "NL",
"errorMessage" : "msg",
"jobId" : "10",
"organizationName" : "us"
}
]
});
})
});
My json Data format
countryCode "NL"
Number "4"
errorMessage "msg"
jobId "1"
organizationName "us"
<!DOCTYPE html>
<html lang="en">
<title>
Boostrap Modal Example
</title>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="bootstrap.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap.css">
<script type="text/javascript">
$(document).ready(function() {
$('#modalTable').on('shown', function() {
$('#table').bootstrapTable({
data: [
{
"Number" : "1",
"countryCode" : "NL",
"errorMessage" : "msg.",
"jobId" : "1",
"organizationName" : "us"
},
{
"Number" : "2",
"countryCode" : "NL",
"errorMessage" : "msg",
"jobId" : "10",
"organizationName" : "us"
}
]
});
})
});
</script>
<body>
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#modalTable">
Launch demo modal
</button>
<div class="modal fade" id="modalTable" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
</div>
<div class="modal-body">
<table id="table">
<thead>
<tr>
<th class="col-xs-1" data-field="jobId">Job ID</th>
<th class="col-xs-1" data-field="Number"> Number</th>
<th class="col-xs-2" data-field="organizationName">Organization Name</th>
<th class="col-xs-1" data-field="countryCode">Country Code</th>
<th class="col-xs-6" data-field="errorMessage"> Error Message</th>
</tr>
</thead>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
</body>
</html>

I tried to populate the json data into my model table. I dont know whats wrong. what is your question actually ?modalTableid belongs to div , not table. you didn't post or write the code for opening modal and didn't provide the code which calls the functionshowFailureJobs