Is it possible to change table row colour if it contains a certain value in a gsp? - grails

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

Related

How to hide the Property name

It's a lot that I used MVC but I need to create a widget using Abp.IO,
What I currently got is
But I want to hide this SenzaAgente and ConAgente, I think this is generated since I use abp-input and it get the value of the property, does exist a way of hiding it and gaining the space (The SENZA Agente on the left should be on the same line of the number)
The code I used is
<abp-table hoverable-rows="true" responsive-sm="true">
<tbody>
<tr>
<td></td>
<td>% RINCARO</td>
</tr>
<tr>
<td>SENZA Agente</td>
<td><abp-input readonly="true" asp-for="#Model.Rincaro.SenzaAgente"></abp-input></td>
</tr>
<tr>
<td>CON Agente</td>
<td><abp-input readonly="true" asp-for="#Model.Rincaro.ConAgente"></abp-input></td>
</tr>
</tbody>
</abp-table>
You can use suppress-label="true" attribute
<abp-table hoverable-rows="true" responsive-sm="true">
<tbody>
<tr>
<td></td>
<td>% RINCARO</td>
</tr>
<tr>
<td>SENZA Agente</td>
<td><abp-input suppress-label="true" readonly="true" asp-for="#Model.Rincaro.SenzaAgente"></abp-input></td>
</tr>
<tr>
<td>CON Agente</td>
<td><abp-input suppress-label="true" readonly="true" asp-for="#Model.Rincaro.ConAgente"></abp-input></td>
</tr>
</tbody>
</abp-table>

Thymeleaf - Suggested approach when tabular data table returns zero records (empty list)?

Given:
<table id="identification-data" class="pure-table">
<thead>
<tr>
<th>Name</th>
<th>DOB</th>
<th>Gender</th>
<tr>
</thead>
<tbody>
<tr th:each="row : ${identificationData}">
<td th:text="${row['Name']}">Brian Smith</td>
<td th:text="${#calendars.format(row['Date of Birth'], 'MM/dd/yyyy')}">10/11/1971</td>
<td th:text="${row['Gender']}">Male</td>
</tr>
</tbody>
</table>
If the collection ${identificationData} is empty - is there a thymeleafy way to show a message like "no data found"?
I could do something on the controller side like:
if (identificationData.isEmpty()){
model.addAttribute("identificationDataNotFound", Boolean.TRUE);
}
model.addAttribute("identificationData", identificationData);
The most "thymeleafy" way that I can think of is to conditionally render a <tbody> containing the "No data found" message if the list is empty. You can use the utility object #lists to check if the list is empty in the UI (saving you one more boolean model attribute)
<tbody th:if="${not #lists.isEmpty(identificationData)}">
<tr th:each="row : ${identificationData}">
...
</tr>
</tbody>
<tbody th:if="${#lists.isEmpty(identificationData)}">
<tr>
<td colspan="3">No Data found</td>
</tr>
</tbody>

Bind list of maps to a table in dart

I have defined the following data model in dart file:
#observable List alist = toObservable([{'rel':'self', 'name':'John'},
{'rel':'Father', 'name':'tom'},
{'rel':'Mother', 'name':'jane'}]);
and table in html as follows:
<table id="summaryTable">
<thead>
<tr>
<th>Name</th>
<th>Ralationship to Me</th>
<th>Update History</th>
<th>Remove Relative</th>
</tr>
</thead>
<tr repeat = "{{p in alist}}">
<td>
{{p['name']}}
</td>
<td>
{{p['rel']}}
</td>
<td>
<button on-click="{{updateClicked}}">Update</button>
</td>
<td>
</td>
</tr>
</table>
The table is not getting populated. What should be changed?
It's hard to tell as you didn't provide much code but at least the template is missing in
<tr template repeat="{{p in alist}}">

Rendering an array of objects in the form of table rows in gsp

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>

Need help: xpath query

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.

Resources