I want to do use for loop in list of groovy , and print the number of i in table .How can I do this with groovy?
<tr>
<td>Options</td>
<td>
#{list i=0 ,items: optionitem, as:'optionitem' , i++}
<td> i </td>
<td>${optionitem}</td>
<td>
#{/list}
</tr>
Assuming you're using Grails...
<tr>
<td>Options</td>
<td>
<g:each in="${options}" var="optionitem" status="i" >
<td>${i}</td>
<td>${optionitem}</td>
</g:each>
</td>
</tr>
Related
I am newbie.
I have a problem how to convert html table with fpdf.
This is my html code
<html>
<body>
<table border=1 align=center>
<tr>
<tr>
<td> </td>
<td>PO1</td>
<td>PO2</td>
</tr>
<tr>
<td>LO1</td>
<td> "THIS WILL TAKE THE VALUE FROM DATABASE " </td>
<td> "THIS WILL TAKE THE VALUE FROM DATABASE " </td>
</tr>
<tr>
<td>LO2</td>
<td> "THIS WILL TAKE THE VALUE FROM DATABASE " </td>
<td> "THIS WILL TAKE THE VALUE FROM DATABASE " </td>
</tr>
</table>
</body>
</html>
Can anyone tell me how to do it?
please take a look the example at http://www.fpdf.org/en/script/script41.php
Let's assume that we have three tables, tbl_student ,tbl_lesson and tbl_score(student_id, lesson_id, score).
for Activedataprovider, we have:
$query = \app\models\Score::find()
->joinWith('student', false)
->joinWith('lesson', false);
$provider = new \yii\data\ActiveDataProvider([
'query' => $array,
]);
echo GridView::widget([
'dataProvider' => $dataProvider,
]);
So it gives an output with columns : student_id, lesson_id, score:
<table border="1">
<tr>
<td> student_id </td>
<td> lesson_id </td>
<td> score </td>
</tr>
<tr>
<td> 1 </td>
<td> 1 </td>
<td> 99.5 </td>
</tr>
<tr>
<td> 1 </td>
<td> 2 </td>
<td> 54 </td>
</tr>
<tr>
<td> 1 </td>
<td> 3 </td>
<td> 87 </td>
</tr>
<tr>
<td> 2 </td>
<td> 1 </td>
<td> 76 </td>
</tr>
<tr>
<td> 2 </td>
<td> 2 </td>
<td> 84 </td>
</tr>
<tr>
<td> 2 </td>
<td> 3 </td>
<td> 69 </td>
</tr>
</table>
But what I want is to display students in the first COLUMN, and lessons in the first ROW and then display the associated scores in the body of the table:
<table border="1">
<tr>
<td>student_id</td>
<td>lesson_1</td>
<td>lesson_2</td>
<td>lesson_3</td>
</tr>
<tr>
<td>1</td>
<td>99.5</td>
<td>54</td>
<td>87</td>
</tr>
<tr>
<td>2</td>
<td>76</td>
<td>84</td>
<td>69</td>
</tr>
</table>
How can I do that?
Thanks in advance.
I know that I can use Arraydataprovider, but as said in Yii2 data providers guide
Note: Compared to Active Data Provider and SQL Data Provider, array data provider is less efficient because it requires loading all data into the memory.
What I want:
but I want to do it using Activedataprovider
I have similiar structure to this:
<table class="superclass">
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
<table cellspacing="0">
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
This is how I get the first table with class:
HtmlNode firstTable = document.DocumentNode.SelectSingleNode("//table[#class=\"superclass\"]");
Then I read the data. However I don't know how to get straight to the another table and read that data too. Any ideas?
I'd rather avoid counting which table it is and then using index to that table.
There is XPath following-sibling axis which allows you to get element following current context element at the same level :
HtmlNode firstTable = document.DocumentNode.SelectSingleNode("//table[#class=\"superclass\"]");
HtmlNode nextTable = firstTable.SelectSingleNode("following-sibling::table");
If you want to access multiple nodes, you can consider SelectNodes(xpath) method over SelectSingleNode(xpath) method.
I'll provide a sample code here for reference, it may not work towards your need.
var tables = htmlDocument.DocumentNode.SelectNodes("//table");
foreach (HtmlNode table in tables)
{
if (table.GetAttributeValue("class", "").Contains("superclass"))
{
//this is the table of class="superclass"
}
else
{
//this is the other table.
}
}
I have a problem to implement table with thin width.
myData = { name:"Foo", age:11, sex:"M", weight:77, height:77, hobby:'gaming'}
I wanna table like belows.
<table>
<tr>
<td>name</td><td>Foo</td><td>age</td><td>11</td>
</tr>
<tr>
<td>sex</td><td>M</td><td>weight</td><td>77</td>
</tr>
<tr>
<td>height</td><td>77</td><td>hobby</td><td>gaming</td>
</tr>
</table>
Is it possible to show data like this using ngRepeat and its built-in variable?
The question John posted would solve your problem but I think it would be less of a hack to use ng-repeat-start and ng-repeat-end e.g.:
<table>
<tr ng-repeat-start="item in myData">
<td>name</td><td>{{item.name}}</td><td>age</td><td>{{item.age}}</td>
</tr>
<tr>
<td>sex</td><td>{{item.sex}}</td><td>weight</td><td>{{item.weight}}</td>
</tr>
<tr ng-repeat-end>
<td>height</td><td>{{item.height}}</td><td>hobby</td><td>{{item.hobby}}</td>
</tr>
</table>
If you have yr myData like this :
myData = [{ name:"Foo", age:11, sex:"M", weight:77, height:77, hobby:'gaming'},{ name:"Foo", age:11, sex:"M", weight:77, height:77, hobby:'gaming'},{ name:"Foo", age:11, sex:"M", weight:77, height:77, hobby:'gaming'}]
Then Your table will be like this :
<table>
<tr ng-repeat="row in myData">
<td>{{row.name}}</td>
<td>{{row.age}}</td>
<td>{{row.sex}}</td>
<td>{{row.weight}}</td>
<td>{{row.height}}</td>
<td>{{row.hobby}}</td>
</tr>
</table>
i need to change quite some html entries in a mysql database. my problem is that some tags need to be replaced while the surrounded code needs to stay the same. in detail: all td-tags in tr-tags with the class "kopf" need to be changed to th-tags (and the addording closing for the tags)
it would not be a problem without the closing tags..
update `tt_content` set `bodytext` = replace(`bodytext`,'<tr class="kopf"><td colspan="2">','<tr><th colspan="2">');
this would work
from what i found the %-sign is used, but how exactly?:
update `tt_content` set `bodytext` = replace(`bodytext`,'<tr class="kopf"><td colspan="2">%</td></tr>','<tr><th colspan="2">%</th></tr>');
i guess this would replace all the code within the old td tags by a %-sign?? how can i achive the needed replacement?
edit: just to clarify things here is a possible entry in the db:
<table class="techDat" > <tbody> <tr class="kopf"> <td colspan="2"> <p><strong>Technical data:</strong></p> </td> </tr> <tr> <td> <p>Operating time depending on battery chargeBetriebszeit je Akkuladung</p> </td> <td> <p>Approx. 4 h</p> </td> </tr> <tr> <td> <p>Maximum volume</p> </td> <td> <p>Approx. 120 dB(A)</p> </td> </tr> <tr> <td> <p>Weight</p> </td> <td> <p>Approx. 59 g</p> </td> </tr> </tbody> </table>
after the mysql replacement it should look like
<table class="techDat" > <tbody> <tr> <th colspan="2"> <p><strong>Technical data:</strong></p> </th> </tr> <tr> <td> <p>Operating time depending on battery chargeBetriebszeit je Akkuladung</p> </td> <td> <p>Approx. 4 h</p> </td> </tr> <tr> <td> <p>Maximum volume</p> </td> <td> <p>Approx. 120 dB(A)</p> </td> </tr> <tr> <td> <p>Weight</p> </td> <td> <p>Approx. 59 g</p> </td> </tr> </tbody> </table>
Try two replaces
update `tt_content` set `bodytext` =
replace(replace(`bodytext`,
'<tr class="kopf"><td colspan="2">','<tr><th colspan="2">'),
'</td></tr>','</th></tr>')
Try updating your records with two queries :
1) for without % sign:
updatett_contentsetbodytext= replace(bodytext,'<tr class="kopf"><td colspan="2">','<tr><th colspan="2">');
2) for % sign
updatett_contentsetbodytext= replace(bodytext,'<tr class="kopf"><td colspan="2">%</td></tr>','<tr><th colspan="2">%</th></tr>')
where instr(bodytext,'%') > 0 ;