I am using smart-table to display a table of employee names, extensions, etc. My data loads fine, but when I try and sort using st-sort it only sorts the top half of the rows. Always half, always the top.
Here's the html code snippet with the table:
<div class="col8" ng-controller="employeeCtrl">
<table st-table="employeesCollection" st-safe-src="employeesCollection" class="table table-striped">
<thead>
<tr>
<th st-sort="firstName" st-skip-natural="true">First Name</th>
<th st-sort="lastName" st-skip-natural="true">Last Name</th>
<th st-sort="extension" st-skip-natural="true">Extension</th>
<th st-sort="city" st-skip-natural="true">Store City</th>
<th st-sort="number" st-skip-natural="true">Store Number</th>
</tr>
<tr>
<td>
<input type="text" id="FirstName" size="10" ng-keyup="searchEmp()" /></td>
<td>
<input type="text" id="LastName" size="10" ng-keyup="searchEmp()" /></td>
<td>
<input type="text" id="Extension" size="10" ng-keyup="searchEmp()" /></td>
<td>
<select id="store" onchange="searchEmp()">
<option value=''>Select City</option>
<% For Each city In cityList%>
<option value="<%=city%>"><%=city%></option>
<% Next%>
</select></td>
<td>
<select id="storeNo" onchange="searchEmp()">
<option value=''>Select Store</option>
<% For Each store In storeList%>
<option value="<%=store%>"><%=store%></option>
<% Next%>
</select>
</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="employee in employeesCollection">
<td ng-repeat="col in employee track by $index">{{col}}</td>
</tr>
</tbody>
</table>
</div>
Anybody got any ideas?
One thing I am noticing, and it may be the issue, is that you are using the same collection in the st-table directive and st-safe-src directive. If you are working with async data, you need to set as in documentation:
st-table="displayedCollection" st-safe-src="rowCollection"
And in your controller:
$scope.displayedCollection = [].concat($scope.rowCollection);
Related
In my Angular Application, I have created a simple Bootstrap Table. Here I want to show the table aligned properly with table headers th with corresponding input fields in td. How can I get th aligned equally with respect to their input fields in the table?
Here I need Name and Email for some input fields.
Here I have shared the jsfiddle link: https://jsfiddle.net/Venkata_Shivaram/8jnasgwr/
Here is my code:
<div class="table-responsive">
<table class="table" style="width: 100%;">
<thead class="card-header">
<tr>
<th>Name</th>
<th>Age</th>
<th>Country</th>
<th>Address</th>
<th>Email</th>
<th>Phone Number</th>
<th>Pincode</th>
<th>City</th>
<th>State</th>
<th>Region</th>
</tr>
</thead>
<tbody>
<tr>
<td class="required-field" colspan="2"><input type="text" class="form-control" formControlName="Name" placeholder="Name"></td>
<td class="required-field" colspan="1"><input type="text" class="form-control" formControlName="Age" placeholder="Age"></td>
<td class="required-field" colspan="1"><input type="text" class="form-control" formControlName="Country" placeholder="Country"></td>
<td class="required-field" colspan="1"><input type="text" class="form-control" formControlName="Address" placeholder="Addess"></td>
<td class="required-field" colspan="2"><input type="text" class="form-control" formControlName="Email" placeholder="email"></td>
<td class="required-field" colspan="1"><input type="text" class="form-control" formControlName="PhoneNumber" placeholder="phonenumber"></td>
<td class="required-field" colspan="1"><input type="text" class= "form-control" formControlName="pincode" placeholder="pincode"></td>
<td class="required-field" colspan="1"><input type="text" class="form-control" formControlName="city" placeholder="City"></td>
<td class="required-field" colspan="1"><input type="text" class="form-control" formControlName="state" placeholder="state"></td>
<td class="required-field" colspan="1"><input type="text" class="form-control" formControlName="Region" placeholder="Region"></td>
</tr>
</tbody>
</table>
I have tried with applying <colgroup> HTML element for th didn't work for me.
<colgroup>
<col>
<col span="2" class="batman">
<col span="2" class="flash">
</colgroup>
You have used colspan="2" for Name and Email. Make it colspan="1".
Read more about colspan here.
I have a table where the user can enter some values and transmit these inputs to my backend via a POST request.
Each row consists of a type, brand and some input fields like buyprice, bottom, top, and stop.
For the purpose that I can connect the input data with the backend data it is important to get the information about the brand which is unique in each row.
Because of that I implemented a hidden input field that the necessary pre-defined value.
But when I check my backend, I only receive the data about buyprice, bottom, top and stop. But nothing about the brand.
Here the relevant passage:
<td th:text="${car.getBrand()}">
<input type="text" name="brand" th:value="${car.getBrand()}" hidden>
</td>
Here the complete table (I use thymleaf as a template-engine)
<div class="container">
<br>
<h4 style="text-align: center">Please specify below</h4>
<br>
<form method="POST">
<table id="buyTable" class="table table-hover">
<thead>
<tr>
<th>Type</th>
<th scope="col">Brand</th>
<th scope="col">Buy-Price</th>
<th scope="col">Bottom</th>
<th scope="col">Top</th>
<th scope="col">Stop</th>
<th>Reduce</th>
<th>Start</th>
</tr>
</thead>
<tbody>
<tr th:each="car : ${cars}">
<td>
<select th:id="${car.getBrand()}" title="selectBuyOrSell" onchange="updateBuyTable(this)">>
<option value="buy">Buy</option>
<option value="sell">Sell</option>
</select>
</td>
<td th:text="${car.getBrand()}">
<input type="hidden" name="brand" th:value="${car.getBrand()}">
</td>
<td><input type="number" step="0.00000001" placeholder="Enter price" name="buyPrice" /></td>
<td><input type="number" step="0.00000001" placeholder="Enter bottom" name="bottom" /></td>
<td><input type="number" step="0.00000001" placeholder="Enter top" name="top" /></td>
<td><input type="number" step="0.00000001" placeholder="Enter stop" name="stop" /></td>
<td>
<label class="custom-control custom-checkbox">
<input id="clickboxReduce" type="checkbox" class="custom-control-input"
onclick="handleClickOnStart(this)" checked>
<span class="custom-control-indicator"></span>
</label>
</td>
<td>
<label class="custom-control custom-checkbox">
<input id="clickboxStart" type="checkbox" class="custom-control-input"
onclick="handleClickOnReduce(this)" checked>
<span class="custom-control-indicator"></span>
</label>
</td>
<!-- <td><input id="clickboxReduce" type="checkbox"></td>
<td><input id="clickboxStart" type="checkbox"></td>-->
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><a style="float:right">Select all</a></td>
<td style="text-align:center"><input type="checkbox" onclick="checkReduce(this)" checked></td>
<td style="text-align:center"><input type="checkbox" onclick="checkInstant(this)" checked></td>
</tr>
</tbody>
</table>
<br/>
<br/>
<button style="float: right!important;" class="btn btn-outline-primary">Continue</button>
<br/>
<br/>
<br/>
<table id="sellTable" class="table table-hover" hidden="true">
<thead>
<tr>
<th>Type</th>
<th>Brand</th>
<th scope="col">Sell-Price</th>
<th scope="col">Amount</th>
</tr>
</thead>
<tbody>
<tr>
</tr>
</tbody>
</table>
</form>
</div>
So it is actually only about getting the brand. Any idea?
Thank you
I figured out that th:text="${car.getBrand()}" within the td tag was overriding the hidden input-field.
So the solution is an a tag and a hidden input within the td tag.
<td>
<a th:text="${car.getBrand()}"></a>
<input type="hidden" name="brand" th:value="${car.getBrand()}"/>
</td>
Hi I am just going through a mysterious condition in my code.
single <td> Or <th> in chrome and Mozilla Firefox don't know why.
<div class="right_content">
<table style="width: 100%; height: 200px; margin-top: 5px;" id="mainTable">
<tr>
<th colspan="1">Participant Name</th>
<td colspan="1">${fullName}<td>
<th colspan="1">Role</th>
<td colspan="1">${role}<td>
<th colspan="1">Brand/Location</th>
<td colspan="1">${location}<td>
</tr>
<tr>
<th>Goal Text</th>
<td><input name="goalText" id="goalText" name="goalText"
class="text_field" size="40" maxlength="95" tabindex="1"
title="Minimum Rating For This Competency" /></td>
<th>Assessment Center</th>
<td><select name="assessmentCenterId" id="assessmentCenterId" class="text_field"
tabindex="2" title="Select Assessment Center">
<option value="-1">--Select Assessment Center--</option>
<c:forEach items="${acList}" var="singleAC" varStatus="sts">
<c:choose>
<c:when test="${singleAC.id eq 0}">
<option value="${singleAC.id}" selected="selected">${singleAC.name} </option>
</c:when>
<c:otherwise>
<option value="${singleAC.id}">${singleAC.name}</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select></td>
<th>Status</th>
<td><select name="status" id="status" class="text_field"
tabindex="3" title="Select Status Of IDP">
<option value="-1" selected="selected">--Select Status--</option>
<c:forEach items="${EnumIDPStatus}" var="singleStatus"
varStatus="sts">
<c:choose>
<c:when test="${(singleStatus.key eq 0) &&(mode eq 'Add')}">
<option value="${singleStatus.key}" selected="selected">${singleStatus.value}</option>
</c:when>
<c:otherwise>
<option value="${singleStatus.key}">${singleStatus.value}</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select></td>
</tr>
<tr>
<th>Score</th>
<td><input type="text" name="score" id="score" class="text_field"
size="40" maxlength="95" tabindex="4" title="Score" /></td>
<th>Target Date</th>
<td><input type="text" name="targetDate" id="targetDate"
class="text_field" title="Minimum Rating For This Competency" /></td>
<th>Extended Date</th>
<td><input type="text" name="extendedDate" id="extendedDate"
class="text_field" /></td>
</tr>
<tr>
<th>Manger Comments</th>
<td><textarea name="managerComments" id="managerComments"
class="text_field" rows="5" cols="50" tabindex="7"
title="Minimum Rating For This Competency"></textarea></td>
<th>Assessor Comments</th>
<td><textarea name="assessorComments" id="assessorComments"
class="text_field" rows="5" cols="50" tabindex="8"
title="Minimum Rating For This Competency"></textarea></td>
<th>Participant Comments</th>
<td><textarea name="participantComments"
id="participantComments" class="text_field" rows="5" cols="50"
tabindex="9" title="Minimum Rating For This Competency"></textarea>
</td>
</tr>
<tr>
<td colspan="6" class="frm_footer_buttons"
style="text-align: center;"><input type="button"
name="btnsubmit" id="btnsubmit" class="frm_button"
value="<spring:message code='button.save' />" tabindex="10"
onclick="return errorPopup();" /> <input type="reset"
class="frm_button" value="Reset" tabindex="11" /> <input
type="button" class="frm_button"
value="<spring:message code='button.cancel'/>" tabindex="12"
onclick="submitRequest('showIDPList.html');" /></td>
</tr>
</table>
</div>
Make sure to always close your HTML tags properly.
Here's a part of your HTML:
<tr>
<th colspan="1">Participant Name</th>
<td colspan="1">${fullName}<td>
<th colspan="1">Role</th>
<td colspan="1">${role}<td>
<th colspan="1">Brand/Location</th>
<td colspan="1">${location}<td>
</tr>
Can you spot a problem?
Look carefully at your closing tags. Your <th> opening tags have proper </th> closing tags, but you <td> don't. They miss / in their closing tags which effectively means you open a new tag instead of closing the previous one.
I have a table were I want to add multiple columns with values when I click an add button. I have a drop down of Rulelist after selecting rule I have a button that rule pass to the controller search the object of that particular rule and display in a table. Now I am facing a problem after adding one column when I want to add another the first column gets removed.
Html
<form:form action="/update" method="post" id="ruleListForm" modelAttribute="ruleListContainer">
<table border="1">
<thead>
<h3 align="center">Selected Rule</h3>
<tr>
<th data-field="id" width="25"> ID </th>
<th data-field="details" width="20">RuleName</th>
<th data-field="details" width="10">StartDate</th>
<th data-field="details" width="10">EndDate</th>
<th data-field="parameter" width="240">Parameter </th>
</tr>
</thead>
<tbody id="ruleListContainer">
<c:forEach items="${ruleList}" var="as" varStatus="vs">
<tr class="rule">
<td><input type="hidden" name="ruleList[${vs.index}].id" value="${as.rule.id}" /> ${as.rule.id}</td>
<td><input type="hidden" name="ruleList[${vs.index}].ruleName" value="${as.rule.ruleName}" /> ${as.rule.ruleName}</td>
<td> <input id="one" class="datepicker" type="text" name="ruleList[${vs.index}].startDate" size="11" height="0.10"></td>
<td> <input id="two" class="datepicker" type="text" name="ruleList[${vs.index}].endDate" size="11" height="0.10"></td>
<td>
<table border="1">
<c:forEach items="${as.ruleParameter}" var="asss">
<tr>
<td><input type="hidden" name="ruleList[${vs.index}].ruleParameter[${assignments.index}].parameterName"value="${asss.parameterName}"> ${asss.parameterName}</td>
<td><input type="hidden" name="ruleList[${vs.index}].ruleParameter[${assignments.index}].parameterValue" value="${asss.parameterValue}" /> ${asss.parameterValue}</td>
<td><input type="text" name="Name" value=""size="2"height="0.01">
<select style="width: 80px;">
<option value="">--Select--</option>
<c:forEach items="${targetlist}" var="target">
<option value="${target.displayName}"/>
<c:out value="${target.displayName}" />
</c:forEach>
</select>
</td>
</tr>
</c:forEach>
</table>
</td>
</tr>
</c:forEach>
</tbody>
</table>
<br>
<input type="submit" value="create">
</form:form>
<div>
<form action="/submitrule" method="post" model="command">
<table>
<tr>
<td colspan="6" align="right">
<select name="Id">
<option value="">--Select--</option>
<c:forEach items="${listRules}" var="rule">
<option>
<c:out value="${rule.id}" />
</option>
</c:forEach>
</select>
<input type="submit" value ="add"></td>
</tr></table></form>
</div>
Controller
#RequestMapping(value = "/submitrule", method = RequestMethod.POST)
public String addruleSerch(#ModelAttribute ("SpringWeb") Rule obj2, ModelMap model) {
model.addAttribute("Id", obj2.getId());
Rule rul = ruleApi.getRule(obj2.getId());
ArrayList<Rule> rl1 = new ArrayList<Rule>();
List<RuleParameter> ptr2 = rul.getRuleParameter();
Iterator it = ptr2.iterator();
while(it.hasNext()) {
RuleParameter r = (RuleParameter) it.next();
System.out.println(r.getParameterName());
System.out.println(r.getParameterValue());
}
rl1.add(rul);
model.addAttribute("ruleList", rl1);
return "hello";
}
How to add multiple column?
Thank you in advance for help/suggestions.
I have a Wordpress plugin with some tables and input forms. The tables are built using the standard Wordpress table widefat class. The input forms are embedded into cells in the widefat table.
Where I am just displaying data, the table resizes to fit the metabox. Where I am using input fields, the table overflows the metabox, see picture:
I would like the input table to resize like the data table.
This is how the normal table renders:
<table class="widefat" id="item_publication_attributes">
<tr>
<th class="type"><b>Type</b></th>
<th class="date"><b>Date</b></th>
<th class="name"><b>Name</b></th>
<th class="address"><b>Address</b></th>
<th class="gender"><b>Map</b></th>
<th></th>
</tr>
<tr class="publish-attribute publish-attribute-1">
<td class="type">Publisher</td>
<td class="date">15/2/1971</td>
<td class="name">Publish Company</td>
<td class="location">63 The Street, The Town, Cambridgeshire</td>
<td class="map-icon" style="font-size:70%">[map]</td>
<td>Delete | Edit</td>
</tr>
</table>
And this is how the Form table renders:
<form>
<input type="hidden" name="post_id" id="add_publishing_attribute_post_id" value=2624/>
<table class="widefat" id="add_new_publishing_attribute">
<tr id="add_new_publishing_attribute_row">
<td class="type">
<select name="type" id="add_attribute_type">
<option value="0">ID 0</option>
<option value="1">ID 1</option>
<option value="2">ID 2</option>
</select>
</td>
<td class="dd"><input type="text" name="dd" id="add_attribute_dd" placeholder="dd" /></td>
<td class="mm"><input type="text" name="mm" id="add_attribute_mm" placeholder="mm" /></td>
<td class="yyyy"><input type="text" name="yyyy" id="add_attribute_yyyy" placeholder="yyyy" /></td>
<td class="name"><input type="text" name="name" id="add_attribute_name" placeholder="name" /></td>
<td class="location"><input type="text" name="location" id="add_attribute_location" placeholder="location" /></td>
<td><input type="submit" name="submit" id="add_new_attribute_submit" value="Add"/></td>
</tr>
</table>
</form>
Grateful for any suggestions
What I don't get is why you're using a form inside a meta box... We just simply drop our input fields there, and save_post takes care of there rest, here's a full example.
To fix the table layout, I've found an answer here: Why is my HTML table not respecting my CSS column width?
Use: table-layout:fixed:
<table class="widefat" id="add_new_publishing_attribute" style="table-layout:fixed">