How to iterate through collection across two columns in Meteor - meteor

I'd like to have a two-column layout to display the returned collection information. Right now I have a two-column layout like:
<template name="Participants">
<div class="container">
<h4 style="text-align: center">{{ReportsMonth}} {{ReportsCamp}} {{ReportsYear}} {{ReportsTitle}}</h4>
{{#each programReports}}
<div class="row">
<div class="col s6">
<h5>Name: {{FullName}}</h5>
<p>Age: {{calculateAge Bdate}}<br> Sex: {{Sex}}<br> Level: {{Level}}<br> Location: {{City}}, {{State}}</p>
</div>
<div class="col s6">
<h5>Name: {{FullName}}</h5>
<p>Age: {{calculateAge Bdate}}<br> Sex: {{Sex}}<br> Level: {{Level}}<br> Location: {{City}}, {{State}}</p>
</div>
</div>
{{/each}}
</div>
</template>
The problem of course is that when it iterates through, it repeats the document across to the next column; it only gets to the next document when it finishes row. Is there a way to have it iterate to fill each div in each row with the next document?
Example:
Current HTML Output:
a a
b b
Desired:
a c
b d
Or:
a b
c d

Best way I can think of for the first example (vertical data rows, a c on same row):
Split your programReports into two helpers: one for the first half, one for the second half.
Make a row and a col s6 outside your #each loops.
Put your items in your each loops in a row and xs12.
I'd love it if someone had a better way to do this, as I've had to do it myself.
Horizontal data rows example (a b on same row):
I think for this one you simply need to get rid of the second col s6 in your each loop. I could be misunderstanding something though.

Related

How to align to highest column in next row in loop?

How to align to highest column in the next row of a loop? I would like it to look like in the first image, not the second. Divs are rendered in loop:
<div class="container">
<div class="row">
<? foreach($a as $b): ?>
<div class="col-xs-12 col-sm-6 col-md-4"" >
$b->foo
</div>
<? endforeach ?>
</div>
</div>
First image (undesirable):
Second image (desirable solution):
This is a side effect of floating, you will need to clear the float on every x-th element, with different “x” for the sm and md breakpoints.
The nth-child selector helps with that. To not have to select the columns based on any specific col-xy-foo class, I would simply go with the child selector here, .row > :nth-child(…), the row itself made more uniquely selectable by an additional class or id, if necessary.

AngularJS pagination in separate columns

I have pagination working in my app. I display 10 elements per page. Now I would like to format these 10 elements into 2 columns (2x 5 elements per 1 page).
I don't know how to start.
<pagination data-boundary-links="true" data-num-pages="noOfPages" data-current-page="currentPage" max-size="maxSize" class="pagination-small" data-previous-text="«" data-next-text="»"></pagination>
Code reference:
http://jsfiddle.net/eqCWL/224/
In your fiddle you are using the older bootstrap2 css, so I'll use it here for the solution:
First, you need to read the bootstrap documentation on scaffolding/grid system
format your HTML to show two lists in two rows:
<div class="row">
<div class="span6">
<li>{{data.name}}</li>
</div>
<div class="span6">
<li>{{data.name}}</li>
</div>
</div>
then, you will need to set the first ng-repeat to show only half of items:
ng-repeat="data in filtered = (list | filter:search) |
startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit/2"
notice limitTo:entryLimit/2
and the second one to show the rest:
ng-repeat="data in filtered = (list | filter:search) |
startFrom:(currentPage-1)*entryLimit + entryLimit/2 | limitTo:entryLimit/2"
you need to change the startFrom filter, to start entryLimit / 2 items later:
startFrom:(currentPage-1)*entryLimit + entryLimit/2
You can test a working example here

How to write 4 colums in one row using Thymeleaf th:each

I have a problem with rendering the Pageable response (using Thymeleaf 2.0.19) content to be displayed in rows of <div class="span3">. The row values are dynamic from Spring 3 MVC controller.
Below is the UI code i need to display product images in rows with each row containing 4 cols of span3.
UI snippet to display the product images in 4 cols per row.
<div class="container">
<div class="row-fluid" th:remove="all-but-first">
<div th:each="asset,assetIter : ${page.content}" th:with="numList=${#strings.listSplit('3,2,1,0', ',')}" th:if="${assetIter.index}%4 == 0" class="span3">
<div class="col-sm-6 col-md-3">
<div class="thumbnail">
<span><img src="../abc.png" /></span>
<div class="caption">
<p>Label1 : <span th:text="${asset.id}">Id</span></p>
<p>Label2: <span th:text="${asset.name}">Name</span></p>
<p>Label3: <span th:text="${asset.category}">Category</span></p>
</div>
</div>
</div>
</div>
</div>
</div>
I tried one of the post responses from "Younghan Kim" posted at in thymeleaf, how can write th:each to combine rows and columns?, however i need to display the values from within the page response object which is however String values in the response above.
So, how do i display the above code as rows with 4 cols. Please provide inputs and let me if i am missing out on something as i am new to thymeleaf impl.
Also the UI pagination is implemented on server side as mentioned in the blog below:
http://www.jiwhiz.com/post/2013/2/Implement_Bootstrap_Pagination_With_SpringData_And_Thymeleaf

Using xpathapply to take only the first h2 node of each row in vector of webscrapes

I am trying to parse a (large) vector of scraped html, more specifically the , but some of the pages in the vector have two in them so the replacement ends up with more rows than the data. My question: how do I take only the first //h2 in every obs?
This is the code that I tried:
data$header = unlist(xpathSApply(htmlParse(data$html, asText=TRUE), '(//h2)[1]', xmlValue))
this gave me only the very first. This code gave me all h2s:
data$header = xpathApply(htmlParse(philly$html, asText=TRUE), '//descendant::h2[1]', xmlValue)
Any help is appreciated
sample with two:
<div id="tutors">
<h1>Tutors</h1>
<div class="tutor">
<h2>John</h2>
<p>...</p>
<div class="tutor">
<h2>Mary</h2>
<p>...</p>
</div>
<div class="tutor">
<h2>David</h2>
<p>...</p>
</div>
</div>
solved it by including the whole root path:
data$header = unlist(xpathApply(htmlParse(data$html, asText=TRUE), '/html/body/h2', xmlValue))

Selenium: how to define css if webpage has mutiple elements with same name

I have the following HTML code:
<table id="userPlaylistTable" cellspacing="0" cellpadding="0">
<div class="numCellWrapper">
<div class="listArrow up" onclick="moveRowUp($(this))"></div>
<div class="numCell"> 1 </div>
<div class="listArrow down" onclick="moveRowDown($(this))"></div>
</div>
<div class="numCellWrapper">
<div class="listArrow up" onclick="moveRowUp($(this))"></div>
<div class="numCell"> 2 </div>
<div class="listArrow down" onclick="moveRowDown($(this))"></div>
</div>
<div class="numCellWrapper">
<div class="listArrow up" onclick="moveRowUp($(this))"></div>
<div class="numCell"> 3 </div>
<div class="listArrow down" onclick="moveRowDown($(this))"></div>
</div>
Basically, now if I define my css as:
css=table#userPlaylistTable div[class='listArrow up']
It picks the first such element it finds. But, how would I have to define my css, so that it picks second element of this type?
So, basically how would I define my css to pick a particular element, if multiple elements of the same kind exist on the page?
Could someone please help me with this query?
Thanks.
You need to do something like:
css=table#userPlaylistTable>div[class='listArrow up']:nth(1)
css=table#userPlaylistTable>div[class='listArrow up']:nth(2)
This will give you the 2nd and the 3rd instance
add [1] which is the index into the array. usually 0 based, so [1] is the second element
css: #userPlaylistTable .listArrow.up:nth-of-type[2]
Instead of [2] replace with item you want to select
Description:
id is # -- #userPlaylistTable
class by . listArrow up, but we have space between class name so replace space with . -- .listArrow.up
:nth-of-type(n) will select child

Resources