I have a table set up like this
<table class="table table-condensed">
<thead>
<tr>
<th>Look</th>
<th>Lease Company</th>
</tr>
</thead>
<tbody data-bind="foreach: leaseApplicationLooks">
<tr>
<td data-bind="text: lookId"></td>
<td><select data-bind="options: $parent.leaseCompanies, optionsText: 'name', optionsValue: 'name', value: leaseCompany" /></td>
</tr>
</tbody>
</table>
My view model:
leaseCompanies(datacontext.lookups.applicationCompanies);
This returns an array with a name, type fields
Depending on the row I want to display different options:
For example:
Row 1, show all Type = 1, 2
Row 2, show all Type = 2
How would I go about doing this?
Set up a different array for each of the types you want. If they are dynamic in length then set up child observable arrays of your leaseApplicationLooks and populate those by iterating through you list of lease companies. It's pretty simple actual, just use plain all javascript loops
Related
How can I prevent Tablesorter from sorting a certain value or keep these values at the bottom? More specifically, this certain value will always be a -
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Name</th>
<th>Number</th>
</tr>
</thead>
<tbody>
<tr>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Bach</td>
<td>40</td>
</tr>
<tr>
<td>Doe</td>
<td>-</td>
</tr>
</tbody>
</table>
I want to keep Doe with the value "-" always at the bottom.
Tablesorter has an emptyTo option which can modify the sort behavior of empty, or non-numeric, cells (demo)
In this case, you might need to set a data-text attribute (modified by the textAttribute option to an empty string.
HTML
<td data-text="">-</td>
JS
$('#myTable').tablesorter({
// ...
emptyTo: 'bottom'
});
This worked for me.
Doc: https://mottie.github.io/tablesorter/docs/example-options-headers-digits-strings.html
jQuery(function($) {
$("#myTable").tablesorter({
stringTo: 'bottom'
});
});
I have a controller action named "save" which is called when a submitButton is pressed and the save action calls a java function and is getting an array of objects as result.Let A be the name of the collection and it is a collection of objects of class B.Now this A is passed as a model to a template named _C.gsp rendered by the action "save".Within _C.gsp,what is needed is to show three properties named name,id,street of each B object, inside the collection A, in a tabular format.What i tried is this:
Template:_C.gsp
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th class="small"><g:message code="Name"/></th>
<th class="medium"><g:message code="ID"/></th>
<th class="tiny"><g:message code="STREET"/></th>
</tr>
</thead>
<tbody>
<g:each in="${A}" >
<g:each in="${A.Name}" status="idx" var="nam" >
<tr>
<td>
${nam}
</td>
<td>
//how can I show id here
</td>
<td>
// how can I show street here
</td>
</g:each>
</g:each>
</tbody>
</table>
PLZ helppp...
There is no need for a double iteration. It should work like this
<g:each in="${A}" var="B">
<tr>
<td>
${B.name}
</td>
<td>
${B.id}
</td>
<td>
${B.street}
</td>
</tr>
</g:each>
I have a table in a gsp containing 10 deiiferent values :
<table class="table table-striped">
<tr>
<th scope="row">Name:</th>
<td>
${person.name}
</td>
</tr>
<tr>
<th scope="row">Address:</th>
<td>
${person.address}
</td>
</tr>............
I need to highlight (either change the background or text clour on some of the values if they are present in an array also available in the gsp.
Is this possible? For example using g:if? Like :
<tr>
<th scope="row">Name:</th>
<td>
<g:if ${array}.contains("${person.name}")>
//change styling of this cell
${person.name}
</g:if>
</td>
</tr>
This should work, but I've not tried it:
<td class="${array.contains( person.name ) ? 'highlight' : ''}">
So if it contains the name, then a 'highlight' class will be added to the td
I have nested tables where both the inner and outer tables have rows added to them dynamically. When I trigger an update of an inner table, after the inner table order has been changed, the order of the outer table is also changed. I've created a jsfiddle to demonstrate this:
http://jsfiddle.net/FZLxp/
which is forked from the OS question Nested jQuery Tablesorter tables, all sortable
To see the problem sort the outer table by Make so that Toyota is at the top and then click the "update" button. The update button triggers an update of the inner toyota table but also sorts the outer table as well to reflect the sort direction of the Toyota Doors column.
How can I sort the inner table after adding additional rows without sorting the outer table as well?
<script type="text/javascript">
function updateRW() {
$("#toyota").trigger("update", [true]);
}
</script>
<table class="tablesorter">
<thead>
<tr>
<th>Make</th>
<th>Model</th>
</tr>
</thead>
<tbody>
<tr>
<td>Honda</td>
<td>Accord</td>
</tr>
<tr class="tablesorter-childRow">
<td colspan="2" style="padding: 0 30px 0 30px;">
<table class="tablesorter-child">
<thead>
<tr>
<th>Doors</th>
<th>Colors</th>
</tr>
</thead>
<tbody>
<tr>
<td>Honda 2-Door</td>
<td>Honda Red</td>
</tr>
<tr>
<td>Honda 4-Door</td>
<td>Honda Blue</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>Toyota</td>
<td>Camry</td>
</tr>
<tr class="tablesorter-childRow">
<td colspan="2" style="padding: 0 30px 0 30px;">
<table id="toyota" class="tablesorter-child">
<thead>
<tr>
<th>Doors</th>
<th>Colors</th>
</tr>
</thead>
<tbody>
<tr>
<td>Toyota 2-Door</td>
<td>Toyota Yellow</td>
</tr>
<tr>
<td>Toyota 4-Door</td>
<td>Toyota Green</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<input type=button value="update" onclick="updateRW()">
$(document).ready(function()
{
$("table").tablesorter({selectorHeaders: '> thead > tr > th'});
});
This appears to be a bug in tablesorter!
I've opened an issue so we can track it, and I should have this fixed in the next update.
Thanks for reporting it!
i want to exclude the IMG Values in this table:
<table class="info">
<tbody>
<tr><th class="round-top" colspan="2">Status</th></tr>
<tr class="even">
<td class="key">Schaltprogramm aktiv</td>
<td class="value"><img height="15" src="./pics/ste-symbol_an-97b765.png"></td>
</tr>
</tbody>
</table>
I want to exclude the values in this table:
<table class="info">
<tbody>
<tr><th class="round-top" colspan="2">Warmwasser</th></tr>
<tr class="even">
<td class="key">WW-Isttemp.</td>
<td class="value">49,0 °C</td>
</tr>
<tr class="odd">
<td class="key round-leftbottom">WW-Solltemp.</td>
<td class="value round-rightbottom">46,5 °C</td>
</tr>
</tbody></table>
Here are my poorly test:
$nodelist = $xpath->query( "//tr/td[substring(#class,1,5)='value']" );
$imgs = $xpath->query("//table[#class='info']/tr/td/img");
What must i do to exclude the IMG Values in the variable "nodelist"?
Any idea?
I think (but am not certain) that you want $nodelist to contain all the td elements whose class attribute begins with the string value but not if they contain an img element.
If that's a correct interpretation of your question, change
$nodelist = $xpath->query( "//tr/td[substring(#class,1,5)='value']" );
to
$nodelist = $xpath->query( "//tr/td[substring(#class,1,5)='value'][not(img)]" );
I'm not clear what it is you want to do about the temperature values in your second sample table; you might want to edit the question to make clearer whether you want to retrieve them or not.