Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
sir i want to show data dynamically in modal when clicking a table row using bootstrap

What I have tried:

//=== js

function BindTable() {
$("#tblselect tbody").find('tr').remove();
var row = "";
$.ajax({
type: "POST",
url: "wsc_common.asmx/bindtable",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
var json = JSON.parse(msg.d);
$.each(json, function (index, obj) {
var row = ' ' + obj.pid + ' ' + obj.p_name + ' ' + obj.p_mobile + ' ' + obj.p_location + ' '
$("#tblselect tbody ").append(row);
});
}
});

}

//=== popup

$(function(){
$('#orderModal').modal({
keyboard: true,
backdrop: "static",
show:false,

}).on('show', function(){
var getIdFromRow = $(event.target).closest('tr').data('id');
//make your ajax call populate items or what even you need
$(this).find('#orderDetails').html($(' Order Id selected: ' + getIdFromRow + ''))
});
});
Posted
Updated 14-Jun-16 17:11pm
v4
Comments
Karthik_Mahalingam 12-Jun-16 4:08am    
what is #orderModal
post the contents of it.
Rajiv.net40 12-Jun-16 4:24am    
<table id="tblselect" runat="server" clientidmode="Static" class="table table-striped">
<thead><tr>
<td></td>
</tr></thead>
<tbody >
<tr data-toggle="modal" data-id="3" data-target="#orderModal">
<td></td>
</tr>
</tbody>
<tfoot><tr>
<td></td>
</tr></tfoot>
</table>

<br />

<div id="orderModal" class="modal hide fade" role="dialog" aria-labelledby="orderModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>

Order



</div>
<div id="orderDetails" class="modal-body"></div>
<div id="orderItems" class="modal-body"></div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
Karthik_Mahalingam 12-Jun-16 4:42am    
on click of what you need to show the modal ?
Rajiv.net40 14-Jun-16 9:57am    
i want to show all details of row on model popup wheen i double click on table row
Karthik_Mahalingam 14-Jun-16 10:00am    
those details are available in the row or from server call ( ajax )

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900