Need support, Initially Django Search page is displaying all data, while i want to have only search text boxes and display data after user input - django

Views.py
def advance_filter(request):
user_list = SarnarLogs.objects.all()
user_filter = UserFilter(request.GET)
return render(request, 'advance_filter.html', {'filter': user_filter})
Template: Advance_filter.html
<form method="get">
<div class="well">
<h4 style="margin-top: 0">Filter</h4>
<div class="row">
<div class="form-group col-sm-4 col-md-3">
{{ filter.form.source.label_tag }}
{% render_field filter.form.source class="searchfield" %}
</div>
<div class="form-group col-sm-4 col-md-3">
{{ filter.form.destination.label_tag }}
{% render_field filter.form.destination class="searchfield" %}
</div>
<div class="form-group col-sm-4 col-md-3">
{{ filter.form.port.label_tag }}
{% render_field filter.form.port class="searchfield" %}
</div>
<div class="form-group col-sm-4 col-md-3">
{{ filter.form.request_no.label_tag }}
{% render_field filter.form.request_no class="searchfield" %}
</div>
</div>
<button type="submit" class="btn btn-primary" placeholder="Search" aria-label="Search" name="q" value='{{ request.GET.q }}'>
<span class="glyphicon glyphicon-search"></span> Search
</button>
</div>
</form><br>
<div class="col-12">
<div class="card my-4">
<div class="card-header p-0 position-relative mt-n4 mx-3 z-index-2">
<div class="bg-gradient-primary shadow-primary border-radius-lg pt-4 pb-3">
<h6 class="text-white text-capitalize ps-3">HUB Requests</h6>
</div>
</div>
<div class="card-body px-0 pb-2">
<div class="table-responsive p-0">
<table class="table align-items-center mb-0">
<thead>
<tr>
<th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">ID</th>
<th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7 ps-2">SOURCE</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">DESTINATION</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">PORT</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">REQUEST TYPE</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">REQUEST_NO</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">REQUESTER</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">START DATE</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">EXPIRY DATE</th>
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Days Left</th>
<th class="text-secondary opacity-7"></th>
</tr>
</thead>
<tbody>
{% for user in filter.qs %}
<tr>
<td>
<div class="d-flex px-2 py-1">
<div class="d-flex flex-column justify-content-center">
<h6 class="mb-0 text-sm">{{user.id}}</h6>
</div>
</div>
</td>
<td>
<p class="text-xs font-weight-bold mb-0">{{user.source}}</p>
</td>
<td class="align-middle text-center text-sm">
<p class="text-xs font-weight-bold mb-0">{{user.destination}}</p>
</td>
<td class="align-middle text-center text-sm">
<p class="text-xs font-weight-bold mb-0">{{user.port}}</p>
</td>
<td class="align-middle text-center text-sm">
<p class="text-xs font-weight-bold mb-0">{{user.request_type}}</p>
</td>
<td class="align-middle text-center text-sm">
<p class="text-xs font-weight-bold mb-0">{{user.request_no}}</p>
</td>
<td class="align-middle text-center text-sm">
<p class="text-xs font-weight-bold mb-0">{{user.requester}}</p>
</td>
<td class="align-middle text-center">
<span class="text-secondary text-xs font-weight-bold">{{user.start_date|date:'d-m-Y'}}</span>
</td>
<td class="align-middle text-center">
<span class="text-secondary text-xs font-weight-bold">{{user.expiry_date|date:'d-m-Y'}}</span>
</td>
<td class="align-middle text-center">
<span class="text-secondary text-xs font-weight-bold">{{ user.expiry_date|timeuntil:user.start_date }}</span>
</td>
</tr>
{% empty %}
<tr>
<td colspan="5">No data</td>
</tr>
{% endfor %}
</tbody>
Any solution to load the page with search boxes and later when user provide inputs and hits the seach to display the data. Problem is that there are millions of records and page is consuming time to load up.
Appriciate if someone can provide insight in resolving it.

Related

Django delete record using modal

I'm new in Django and i like to implement a Modal to delete records. The problem is a funny error in the modal form because is expecting a parameter. The modal link has this
but I don't know how add the right parameter.
This is my List in html
<table id="tablaAlmacenes" class="table table-bordered table-striped">
<thead>
<tr>
<th>Almacén</th>
<th>Detalles</th>
<th></th>
</tr>
</thead>
<tbody>
{% for almacen in object_list %}
<tr>
<td>{{ almacen.almacen }}</td>
<td>{{ almacen.descripcion }}</td>
<td>
<div>
Detalles
<a a href="" class="btn btn-link text-primary">Editar</a>
<a class="btn btn-link deleteAlmacen" data-id="{{ almacen.id}}"><span class="fas fa-trash text-danger"></a>
</div>
</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<th>Almacén</th>
<th>Detalles</th>
<th></th>
</tr>
</tfoot>
</table>
this is my url.py
urlpatterns = [
path('',include('polls.urls'),name='home'),
path('admin/', admin.site.urls),
# path('contact/',views.contact, name='contacto')
path('almacenes/', AlmacenesListView.as_view(), name='almacenes'),
path('almacenes/nuevo', AlmacenesCreateView.as_view(), name='crear_almacen'),
path('almacenes/<int:id>/remove/', AlmacenesDeleteView.as_view(), name='eliminar_almacen')
]
This is my views.py
class AlmacenesListView(ListView):
model = Almacen
template_name = 'pages/index.html'
success_message = "Bien!!!!"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['title'] = "Lista de Almacenes"
print(reverse_lazy('almacenes'))
return context
class AlmacenesCreateView(SuccessMessageMixin, CreateView):
model = Almacen
form_class = AlmacenesForm
success_url = reverse_lazy('almacenes')
success_message = "Bien!!!!"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
return context
class AlmacenesDeleteView(DeleteView):
model = Almacen
success_url = reverse_lazy('almacenes')
and my modal code
<div class="modal fade" aria-modal="false" id="deleteAlmacenModal">
<div class="modal-dialog modal-dialog-centered modal-sm">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Confirmación</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Cerrar">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>¿Desea eliminar el Almacen?</p>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
<form action="{% url 'eliminar_almacen' (some parameter here but error) %}" method="POST">
{% csrf_token %}
<input type="hidden" name="id" id="almacen_id"/>
<button type="submit" class="btn btn-danger">Eliminar</button>
</form>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
scrpt for modal
$(document).on('click','.deleteAlmacen',function(){
var id_almacen=$(this).attr('data-id');
$('#almacen_id').val(id_almacen);
$('#deleteAlmacenModal').modal('show');
});
So, if you are using bootstrap you don't need to trigger the modal with jquery but let bootstrap do the magic.
Your code should be something like that:
html:
<table id="tablaAlmacenes" class="table table-bordered table-striped">
<thead>
<tr>
<th>Almacén</th>
<th>Detalles</th>
<th></th>
</tr>
</thead>
<tbody>
{% for almacen in object_list %}
<tr>
<td>{{ almacen.almacen }}</td>
<td>{{ almacen.descripcion }}</td>
<td>
<div>
Detalles
<a a href="" class="btn btn-link text-primary">Editar</a>
<a class="btn btn-link" data-toggle="modal" data-target="#deleteAlmacenModal{{almacen.id}}""><span class="fas fa-trash text-danger"></a> <!-- data-toggle and data-target work in bootstrap4, in 5 is data-bs-target and data-bs-toggle -->
{% include 'yourtemplatefolder/modals/delete_almacen_modal.html' %} <!-- as best practice create another folder called modals and put there you modal.html files, as in this case and include them in your code -->
</div>
</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<th>Almacén</th>
<th>Detalles</th>
<th></th>
</tr>
</tfoot>
</table>
Now, being the modal called inside the for loop, you can fix your modal like this:
delete_almacen_modal.html
<div class="modal fade" aria-modal="false" id="deleteAlmacenModal{{almacen.id}}">
<div class="modal-dialog modal-dialog-centered modal-sm">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Confirmación</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Cerrar">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>¿Desea eliminar el Almacen?</p>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
<form action="{% url 'eliminar_almacen' pk=almacen.id %}" method="POST">
{% csrf_token %}
<input type="hidden" name="id" id="almacen_id"/>
<button type="submit" class="btn btn-danger">Eliminar</button>
</form>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
Now that should work.

bootstrap 4 nested column not stacking

new to bootstrap and experimenting on a pet project. am a bit at my wits ends here.
my understanding is if you have <div class="col-sm-12 col-lg-5"> and <div class="col-sm-12 col-lg-7 "> on small screen each would take a new row (12 cols). vs on a large screen they'd share the row (5+7). in my code the second table(fruits) is supposed to share row with the chart on large screens and split on small screen but when I try small screens in debugging mode, the second column with the chart gets pushed out of the parent column (off screen). I have no clue what exactly is wrong here. any help would be appreciated
bellow is a portion of the code
<div class="container">
<div class="row">
<div class="media content-section col-sm-12 col-md-12 col-lg-12">
<form action="" method="post">
{% csrf_token %}
<label class="switch"
><input type="checkbox" id="togBtn" />
<div class="slider round">
<!--ADDED HTML --><span class="on">BUY</span
><span class="off">SELL</span
><!--END-->
</div></label
>
<div class="table-responsive-md">
<table class="table table-sm table-bordered tableformat">
<thead>
SUMMARY
<small class="text-muted"
>(edit cells to adjust position)</small
>
<tr>
<th scope="col">col 1</th>
<th scope="col">col 2</th>
<th scope="col">col 3</th>
<th scope="col">col 4</th>
<th scope="col">col 5</th>
<th scope="col">col 6</th>
<th scope="col">col 7</th>
<th scope="col">col 8</th>
<th scope="col">col 9</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td width="60">
<input
type="text"
maxlength="10"
width="50%"
placeholder="1"
size="10"
/>
</td>
<td width="60">
<input
type="text"
maxlength="10"
width="50%"
size="10"
placeholder="2"
/>
</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
</tbody>
</table>
</div>
<div class="row">
<div class="col-md">
<button
type="button"
class="btn btn-primary btn-sm"
type="submit"
>
update position
</button>
<button
type="button"
class="btn btn-primary btn-sm"
type="submit"
>
reset to default
</button>
</div>
</div>
</form>
</div>
</div>
<div class="row">
<div class="media content-section col-sm-12-col-md-12 col-lg-12">
<div class="col-sm-12 col-lg-5">
<div class="table-responsive-md">
<table
class="table table-sm table-bordered tableformat text-center"
>
<thead>
fruits
<small class="text-muted"
>(hover on terms for quick definitions)</small
>
<tr>
<th scope="col">mango</th>
<th scope="col">banana</th>
<th scope="col">apple</th>
<th scope="col">peach</th>
<th scope="col">grapes</th>
<th scope="col">lemon</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="chart col-sm-12 col-lg-7 overflow-auto">
<div style="width: 560; height: 400;">
<canvas id="plchart"></canvas>
</div>
</div>
</div>
</div>
here is how it looks in debugging mode on large screen vs on small screen. I have in the meta tag <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
solved it. I missed the inner row before the cols.
essentially should be something like container->row->outer col->inner row -> inner-cols. I was doing container->row-> outer col -> inner cols

How to pass multiple parameters from 'if condition' to 'for loop' in Django?

I have the following code :
{% if sr %}
{% for lap in filter.qs|slice:":20" %}
<tr >
<td class="col-sm-3">
<div >
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="{{ lap.product_image }}" alt="" />
</div>
</div>
</div>
</div>
</td>
<td class="col-sm-3">
<h5>{{ lap.product_name }} </h5>
<br>
{# <h5 class="btn btn-outline-secondary"><a href="{{ k.product_url }}" >See Details</a> </h5>#}
<a href="{{ lap.product_url }}" class="btn btn-secondary" role="button" aria-pressed="true"
style="background-color: #3e4e6f; color: white">See Details</a>
</td>
<td class="col-sm-3">{{ lap.product_price }} ৳</td>
<td class="col-sm-3">{{ lap.vendor_name }}</td>
</tr>
{% empty %}
<tr>
<td colspan="5">No data</td>
</tr>
{% endfor %}
{% endif %}
Where I want to pass the parameter sr from if loop to the next for loop along the existing filter.qs|slice:":20" parameter in the following part.
{% if sr %}
{% for lap in filter.qs|slice:":20" %}
How can I pass it? Please help.

Django Graphos Chart Not Loaded On Table Update Using Ajax

I have been using django graphos and it works fine till i realize that the chart is not drawn when i update my table through ajax instead of a page refresh. Let me describe the issue further.
When my page is loaded for the first time, all the charts are loaded properly using {{chart.as_html}} . I am usng django by the way .
This charts are displayed in a table.
But when user selects different value from a dropdown and click reload, my code will only update the table through ajax instead of a whole page refresh. Unfortunately , when the table is updated, the chart with new data is not displayed. It just appears blank. I can see all the data from the developer tools but the chart just fail to appear.
I have checked through various topics but I am unable to get it working.
Part of my main html file
{% if objects %}
{% for obj in objects %}
<tr data-toggle="collapse" data-target="#{{obj.name}}" data-parent="#myGroup" class="accordion-toggle">
<!--tr>-->
<td style="border:0;"><img src='{{STATIC_URL}}/static/images/{{obj.name}}.png' class="infostockIcon"></td>
{% if obj.risk == "high" %}
{% if obj.dpr == "high" %}
<td class="tablerisk"><strong> * {{obj.name}} </strong></td>
{% else %}
<td class="tablerisk"><strong> {{obj.name}} </strong></td>
{% endif %}
<td class="tablerisk"> {{obj.stock_price}} </td>
<td class="tablerisk" style="color: black;"> {{obj.option_strategy}} </td>
<td class="tablerisk" style="color: black;"> {{obj.whiz_strategy}} </td>
<td class="tablerisk"> {{obj.strike_price}} </td>
<td class="tablerisk"> {{obj.expiry_date}} </td>
<td class="tablerisk"> {{obj.premium}} </td>
<td class="tablerisk"> {{obj.roi}} </td>
{% else %}
{% if obj.dpr == "high" %}
<td><strong> * {{obj.name}} </strong></td>
{% else %}
<td><strong> {{obj.name}} </strong></td>
{% endif %}
<td> {{obj.stock_price}} </td>
<td> {{obj.option_strategy}} </td>
<td> {{obj.whiz_strategy}} </td>
<td> {{obj.strike_price}} </td>
<td> {{obj.expiry_date}} </td>
<td> {{obj.premium}} </td>
<td> {{obj.roi}} </td>
{% endif %}
<td style="border:0;"><span class="caret black"></span></th></td>
</tr>
<tr>
<td style="border: 0;padding: 0 !important;"></td>
<td colspan="8" style="padding: 0 !important; border: none;">
<div class="accordion-body collapse" id="{{obj.name}}">
<ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
<li data-toggle="tab" class="active">
Monthly Seasonality
</li>
<li data-toggle="tab">
Weekly Seasonality
</li>
<li data-toggle="tab">
Dividend
</li>
<li data-toggle="tab">
{{obj.name}} Info
</li>
</ul>
<div id="my-tab-content" class="tab-content">
<div class="tab-pane active" id="{{obj.name}}monthseason">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<h4>Monthly Seasonality<img src='{{STATIC_URL}}/static/info.png' class="infoIcon" style="float: none; right: 0px; margin-left: 5px" /></h4>
<div id="gchart_div">
{{ obj.monthly_chart.as_html}}
</div>
</div>
</div>
</div>
<div class="tab-pane" id="{{obj.name}}weekseason">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<h4>Weekly Seasonality<img src='{{STATIC_URL}}/static/info.png' class="infoIcon" style="float: none; right: 0px; margin-left: 5px"/></h4>
{{ obj.weekly_chart.as_html}}
</div>
</div>
</div>
<div class="tab-pane" id="{{obj.name}}dividend">
<!--div style="padding-left: 2%;" >-->
<div class="row">
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >TTM Dividend Yield:</label>
<label >{{obj.ttm_dividend_yield}}</label>
</div>
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >Ex-Dividend Date:</label>
<label >{{obj.ex_div}}</label>
</div>
</div>
<!--/div>-->
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<h4>Dividend Yield<img src='{{STATIC_URL}}/static/info.png' class="infoIcon" style="float: none; right: 0px; margin-left: 5px"/></h4>
{{obj.div_yearly_chart.as_html}}
</div>
</div>
</div>
<div class="tab-pane alignRight" id="{{obj.name}}data">
<div style="padding-left: 2%;" >
<div class="row">
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >Sector:</label>
<label >{{obj.sector}}</label>
</div>
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >Industry:</label>
<label >{{obj.industry}}</label>
</div>
</div>
<div class="row">
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >Earning Date:</label>
<label >{{obj.earnings_date}}</label>
</div>
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >Ex-Dividend Date:</label>
<label >{{obj.ex_div}}</label>
</div>
</div>
<div class="row">
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >52 Week Range:</label>
<label >{{obj.year_range}}</label>
</div>
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >5 Year Low:</label>
<label >{{obj.five_year_low}}</label>
</div>
</div>
<div class="row">
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >DPR:</label>
<label >{{obj.dpr_value}}</label>
</div>
<div class="col-md-5 col-xs-6 col-sm-6 alignLeft">
<label >Latest News:</label>
<a href={{obj.url}}>Seeking Alpha</a>
</div>
</div>
</div>
<br>
</div>
</div>
</div>
</td>
</tr>
My ajax call:
`var $myGroup = $('#myGroup');
$myGroup.on('show.bs.collapse','.collapse', function() {
$myGroup.find('.collapse.in').collapse('hide');
});
$('#tabs li a').click(function (e) {
$('#tabs li a.active').removeClass('active');
$(this).parent('li a').addClass('active');
});
$("#loadprofit").on("click", function(e)
{
//alert("asdas");
e.preventDefault();
var selectedOption = $("#strategy").val();
var selectedDate = $("#strategy2").val();
csrf_token = "{{ csrf_token }}";
$.ajax({
method: "POST",
url: window.location.href,
data: { selected_option: selectedOption,selected_date:selectedDate,csrfmiddlewaretoken: csrf_token },
})
.done(function( msg )
{
console.log(msg);
$("#sct tbody").html(msg);
});
});
</script>
{% endblock %}
`
This whole table gets updated when user clicks on a button. Then it calls views.py and table gets updated with the latest value. But {{ obj.monthly_chart.as_html}} is not loaded and it appears blank although i can see the whole chart drawing function and the data form the developer tool
Any help is greatly appreciated.

Bootstrap Modal not work correctly

I have a jsa page Test.jsp page .There are two modal in the page.data is dynamically loded in modal. second modal open at first modal link.when both modal are open when i close second modal first modal also close and also scroll is not work correctly.
FIRST MODAL
<div id="panelModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Department Details</h4>
</div>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover">
<tbody>
<tr>
<td class="col-md-2">Panel Name</td>
<td class="col-md-2">
<label id="panel1" text=""></label></td>
<td class="col-md-2">Panel Price</td>
<td class="col-md-2">
<label id="price1" text=""></label></td>
<td class="col-md-2">Description</td>
<td class="col-md-2">
<label id="description1"></label></td>
</tr>
<tr>
<td class="col-md-2">Mapped Test </td>
<td class="col-md-2" id="tests">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
SECOND MODAL
<div id="testModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Test Details</h4>
</div>
<!-- <div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-body"> -->
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover">
<tbody>
<tr>
<td class="col-md-2">Test Common Name</td>
<td class="col-md-2">
<label id="testName1" text=""></label></td>
<td class="col-md-2">Test Technical Name</td>
<td class="col-md-2">
<label id="technicalName"></label></td>
<td class="col-md-2">Test Area</td>
<td class="col-md-2">
<label id="testArea1"></label></td>
</tr>
<tr>
<td class="col-md-2">Technology Long Form</td>
<td class="col-md-2">
<label id="testCategory1"></label></td>
<td class="col-md-2">Technology Short Form</td>
<td class="col-md-2">
<label id="testCategory2"></label></td>
<td class="col-md-2">Sub Test Technology</td>
<td class="col-md-2">
<label id="subTestCategory1"></label></td>
</tr>
<tr>
<td class="col-md-2">TAT</td>
<td class="col-md-2">
<label id="tat1"></label></td>
<td class="col-md-2">Test MRP</td>
<td class="col-md-2">
<label id="testMrp1"></label></td>
<td class="col-md-2">Specimen Type</td>
<td class="col-md-2" id="specimenType1">
</td>
</tr>
<tr>
<td class="col-md-2">Preservation</td>
<td class="col-md-2">
<label id="preservation1"></label></td>
<td class="col-md-2">Comment</td>
<td class="col-md-2">
<label id="comment1"></label></td>
<td class="col-md-2">NABL Accredited</td>
<td class="col-md-2">
<label id="nablAccredited"></label></td>
</tr>
<tr>
<td class="col-md-2">Test Type</td>
<td class="col-md-2">
<label id="testType1"></label></td>
<td class="col-md-2">Site</td>
<td class="col-md-2">
<label id="site1"></label></td>
<td class="col-md-2">Department</td>
<td class="col-md-2">
<label id="department1"></label></td>
</tr>
<tr>
<td class="col-md-2">Sub Department</td>
<td class="col-md-2">
<label id="subdepartment1"></label></td>
<td class="col-md-2">Description</td>
<td class="col-md-2">
<label id="description1"></label></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
You can use z-Index to solve your problem. For example:
var zIndex = 1040 + (10 * $('.modal:visible').length);
$(this).css('z-index', zIndex);
setTimeout(function() {
$('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
}, 0);
Here is jsFiddle Demo