Why does my Thyme leaf creates such a big gap when I use the following code below.
BAD/WARNING
</h3>
<h3>
APPLICATION PROCESSING
</h3>
<table class="tablebad">
<tr>
<th> Status </th>
<th> HostName </th>
<th> Process Name </th>
<th> Process Count </th>
</tr>
<tr th:each="DartModel, iterStat : ${countlist}">
<td th:if ="${DartModel.Status == 'BAD'}" th:text="${DartModel.Status}"></td>
<td th:if="${DartModel.Status == 'BAD'}" th:text="${DartModel.host}"></td>
<td th:if="${DartModel.Status == 'BAD'}" th:text="${DartModel.processName}"></td>
<td th:if="${DartModel.Status == 'BAD'}" th:text="${DartModel.processCount}"></td>
</tr>
</table>
<h3>
APPLICATION PROCESSING
</h3>
<table class="tableok">
<thead>
<tr>
<th> Status </th>
<th> HostName </th>
<th> Process Name </th>
<th> Process Count </th>
</tr>
</thead>
<tbody>
<tr th:each="DartModel, iterStat : ${countlist}">
<td th:if="${DartModel.Status == 'OK'}" th:text ="${DartModel.Status}"></td>
<td th:if="${DartModel.Status == 'OK'}" th:text="${DartModel.host}"></td>
<td th:if="${DartModel.Status == 'OK'}" th:text="${DartModel.processName}"></td>
<td th:if="${DartModel.Status == 'OK'}" th:text="${DartModel.processCount}"></td>
</tr>
</tbody>
</table>
Result
and under this will be all my data printed out with the status of "OK". I am ultimately trying to sort the data based on value. I tried working with javascript/jquery but it was too complicated. I found a way to split the data rows based on values. If values is "BAD" display table above vice versa to values with "OK"
Am I doing this wrong? I
The problem is that your are putting the th:if on the <td> elements instead of the <tr>. This means that your html looks something like this (where you have several empty rows between each non-empty row.
<table>
<tr>
<td>BAD</td>
<td>...</td>
<td>...</td>
</tr>
<tr></tr>
<tr></tr>
<tr>
<td>BAD</td>
<td>...</td>
<td>...</td>
</tr>
<tr></tr>
</table>
You should just move the th:if to the <tr> element, like so:
<table class="tablebad">
<tr>
<th>Status</th>
<th>HostName</th>
<th>Process Name</th>
<th>Process Count</th>
</tr>
<tr th:each="DartModel, iterStat : ${countlist}" th:if="${DartModel.Status == 'BAD'}">
<td th:text="${DartModel.Status}" />
<td th:text="${DartModel.host}" />
<td th:text="${DartModel.processName}" />
<td th:text="${DartModel.processCount}" />
</tr>
</table>
Related
I'm using Mottie's tablesorter plugin with the Math extension. I have a conditionally formatted table - the categories of conditional formatting are indicated in a data-color attribute on the data cell.
In the footer, I have several rows that summarize the values of the conditional formatting. The footer cells are decorated with data-math-filter="[data-color='color1']".
<table>
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td data-color='red' style='background-color:red'>
3
</td>
<td data-color='blue' style='background-color:blue'>
7
</td>
</tr>
<tr>
<td data-color='green' style='background-color:green'>
6
</td>
<td data-color='red' style='background-color:red'>
4
</td>
</tbody>
<tfoot>
<tr>
<td data-math-filter='[data-color="red"]' data-math='col-sum'></td>
<td data-math-filter='[data-color="red"]' data-math='col-sum'></td>
</tr>
<tr>
<td data-math-filter='[data-color="green"]' data-math='col-sum'></td>
<td data-math-filter='[data-color="green"]' data-math='col-sum'></td>
</tr>
<tr>
<td data-math-filter='[data-color="blue"]' data-math='col-sum'></td>
<td data-math-filter='[data-color="blue"]' data-math='col-sum'></td>
</tr>
</tfoot>
</table>
My reading of the docs leads me to believe that the math function will filter for the data-elements - but it doesn't seem to work. I've tried a bunch of different CSS filters - nothing seems to work.
What am I doing wrong?
Here is the error i am facing. My code seems fine where i have two data models. Both models are stored in the database as table. Now in the CSHTML (Razor view page) it throws exception on
#foreach(var obj in Model)
But it says Model is Null. Please help to resolve the issue.
Here is the code:
enter image description here
#if (Model.Count() > 0)
{
<table class="table-bordered table-striped" style= "width: 100%">
<thead>
<tr>
<th>
Work Order Number
</th>
<th>
Part Number
</th>
<th>
Welding Points
</th>
<th>
Target Work Center
</th>
<th>
Operator
</th>
<th>
Standard Cycle Time
</th>
</tr>
</thead>
<tbody>
#foreach (var obj in Model)
{
<td width="30%">#obj.WorkOrderNumber</td>
<td width="30%">#obj.PartNumber</td>
<td width="30%">#obj.WeldingPoints</td>
<td width="30%">#obj.TargetWorkCenter</td>
<td width="30%">#obj.Operator</td>
<td width="30%">#obj.StandarCycleTime</td>
}
</tbody>
</table>
}
else
{
<p><strong>No Data to Display!</strong></p>
}
I have 1000 records and I am able to fetch them from database like in one second. But they are taking like 9s for rendering. It is maybe because of data tables or I am looping through each record to display. If I disable the data tables performance is better but still not good. Following is my code, could you give your suggestions. I am pretty sure it is slow because of rendering and scripting.
<div class="table-responsive">
<table class="display" id="list" cellspacing="0">
<thead>
<tr>
<th>
#Content.Code
</th>
<th> #Content.Name </th>
<th>
#Content.Location
</th>
<th>
#Content.Date
</th>
<th> #Content.Remaining </th>
<th>
#Content.Status
</th>
<th>
</th>
</tr>
</thead>
<tbody>
#foreach (var item in Model)
{
<tr>
<td>
#item.Code
</td>
<td>
#item.Name
</td>
<td>
#item.Location
</td>
<td>
#item.Date
</td>
<td>
#item.ReDays
</td>
<td>
#item.Status
</td>
<td width="15%">
<i class="fa fa-pencil" aria-hidden="true"></i>
#if (User.IsInRole("Admin") || ViewBag.HavePermission == true)
{
<i class="fa fa-trash" aria-hidden="true"></i>
}
</td>
</tr>
}
</tbody>
</table>
</div>
I don't want to use server-side processing because I don't know how to control this HavePermisson and UserRole part. Please, give a suggestion?
So I am trying to make bootstrap table with search and sorting with the data coming from a GET calll
<table id="example" class="table table-bordered table-striped table-hover" data-search="true">
<thead>
<tr class="text-white clickable-row" bgcolor="#578ebe" >
<th id="white-text"> # </th>
<th id="white-text"> Name </th>
<th id="white-text"> DBA </th>
<th id="white-text"> Facility ID </th>
<th id="white-text"> Active </th>
</tr>
</thead>
<tbody>
<tr ng-repeat="hospital in hospital_filtered = hospitals">
<td> <a ng-click="click(hospital)"> {{ hospital.hospital_id }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.hospital_name }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.hospital_dba }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.facility_id }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.active_flag }} </td>
</tr>
</tbody>
</table>
Here is where I make the GET call from my API. The data is coming in, but the bootstrap table sorting and sort are not working. How do I populate bootstrap table with this call?
$http.get("/hospitals/all", {
params: {authtoken: $rootScope.auth_token}}
)
.then(function(response) {
// Request completed successfully
//console.log(response);
$scope.hospitals=response.data
}, function(x) {
// Request error
console.log("Error");
});
});
You're correctly fetching the data, but the iteration is wrong.
HTML:
<input ng-model="searchKeyword" type="text">
<table id="example" class="table table-bordered table-striped table-hover" data-search="true">
<thead>
<tr class="text-white clickable-row" bgcolor="#578ebe" >
<th id="white-text" ng-click="changeSort('hospital_id')"> # </th>
<th id="white-text" ng-click="changeSort('hospital_name')"> Name </th>
<th id="white-text" ng-click="changeSort('hospital_dba')"> DBA </th>
<th id="white-text" ng-click="changeSort('facility_id')"> Facility ID </th>
<th id="white-text" ng-click="changeSort('active_flag')"> Active </th>
</tr>
</thead>
<tbody>
<tr ng-repeat="hospital in hospitals | filter: searchKeyword | orderBy: orderKeyword">
<td> <a ng-click="click(hospital)"> {{ hospital.hospital_id }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.hospital_name }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.hospital_dba }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.facility_id }} </td>
<td> <a ng-click="click(hospital)"> {{ hospital.active_flag }} </td>
</tr>
</tbody>
</table>
The Javascript part:
$scope.orderKeyword = 'hospital_name';
$scope.changeSort = function(sortAttr) {
$scope.orderKeyword = sortAttr;
};
filter: searchKeyword will use the keyword typed into the additional input-field. This way you can basically "search" the table. The results that are left will then be ordered by (orderBy) the attribute-name that's stored inside $scope.orderKeyword. I initialized it with hospital_name.
You may add additional logic like how strict the filtering and which direction the sorting is supposed to be.
Here's the documentation for the two filters in question:
https://docs.angularjs.org/api/ng/filter/orderBy
https://docs.angularjs.org/api/ng/filter/filter
In my ASP.NET MVC Core app that uses Bootstrap (installed by default by Visual Studio 2015 MVC Core project), I need to use ID column in a controller but want to hide it in the View. But the following View still displays the column as blank. I would like to hide the first columns that is the ID column
View:
#model List<myProj.Models.StateName>
<form id="target" asp-controller="TestController" asp-action="TestAction" asp-route-returnurl="#ViewData[" ReturnUrl"]" method="post">
<table class="table">
<thead>
<tr>
<th></th>
<th>
State Name
</th>
<th>
State Code
</th>
</tr>
</thead>
<tbody>
#for (int i = 0; i < Model.Count(); i++)
{
<tr>
<td><input asp-for="#Model[i].StateId" type="hidden" /></td>
<td>
<label asp-for="#Model[i].State"></label>
</td>
<td>
<input asp-for="#Model[i].StateCode" type="text" readonly style="border:0px;"/>
</td>
</tr>
}
</tbody>
</table>
<button type="submit" class="btn btn-default">Save</button>
</form>
I've tested the behavior you describe in this pen. The "Bad Table" version demonstrates what I believe you are likely seeing and occurs by neglecting to add display:none to one single th/td in that column. The "Good Table" version has the first column completely hidden and stretches to fill the entire available width.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<h2>Good Table</h2>
<table class="table">
<thead>
<tr>
<th style="display:none">Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
</thead>
<tbody>
<tr>
<td style="display:none">Data 1.1</td>
<td>Data 1.2</td>
<td>Data 1.3</td>
</tr>
<tr>
<td style="display:none">Data 2.1</td>
<td>Data 2.2</td>
<td>Data 2.3</td>
</tr>
<tr>
<td style="display:none">Data 3.1</td>
<td>Data 3.2</td>
<td>Data 3.3</td>
</tr>
</tbody>
</table>
<h2>Bad Table</h2>
<table class="table">
<thead>
<tr>
<th style="display:none">Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
</thead>
<tbody>
<tr>
<td style="display:none">Data 1.1</td>
<td>Data 1.2</td>
<td>Data 1.3</td>
</tr>
<tr>
<td>Data 2.1</td> <!-- WHOOPS -->
<td>Data 2.2</td>
<td>Data 2.3</td>
</tr>
<tr>
<td style="display:none">Data 3.1</td>
<td>Data 3.2</td>
<td>Data 3.3</td>
</tr>
</tbody>
</table>
Long and short, check the rendered output and ensure that each th/td in the column you are hiding ended up with the display:none style.