Big table, numerate positions

24 views
Skip to first unread message

Maciej Bąk

unread,
Aug 26, 2016, 2:46:00 AM8/26/16
to Lift
HI,

Im rendering quite big table ( over 100 positions ). 
In each I have <td class="position"></td>
Is it possible to somehow make working : 
(1.to(114).map(num => ".position" #> num)) ?

Maciej Bąk

unread,
Aug 26, 2016, 4:58:37 AM8/26/16
to Lift
I tried also "#appUserStatTbl *" #> (1.to(114).map(num => ".position *" #> num.toString)) but crap it renders table 114 times :(

Diego Medina

unread,
Aug 26, 2016, 7:42:40 AM8/26/16
to Lift
you were really close!

try

"#appUserStatTbl" #> (1.to(114).map(num => ".position *" #> num.toString)) but crap it renders table 114 times :(

I just removed the * after #appUserStatTbl

Thanks

Diego







--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Diego Medina
Lift/Scala Consultant
di...@fmpwizard.com
http://blog.fmpwizard.com/

Maciej Bąk

unread,
Aug 26, 2016, 8:03:40 AM8/26/16
to Lift
Then it generated 114 times whole table :(

def renderNums = "#appUserStatTbl" #> (1.to(114).map(num => ".position *" #> num.toString))
def sendSnapshot(): Unit = {
val html = Templates("admin" :: "app" :: "statistics" :: Nil).getOrElse(<span>Template Not found</span>)
val out = (renderNums(Statistics.listStatistics(html))).toString

<div class="l:Statistics.listStatistics">

<h3>User Statistics - <span name="generation-date">Date and Time</span></h3>

<center>
<table id="appUserStatTbl" class="tablesorter" style="width: 80%" border="1" >
<thead>
<tr>
<th>Position</th>
<th>Statistic</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td class="position"></td>

W dniu piątek, 26 sierpnia 2016 13:42:40 UTC+2 użytkownik fmpwizard napisał:
you were really close!

try

"#appUserStatTbl" #> (1.to(114).map(num => ".position *" #> num.toString)) but crap it renders table 114 times :(

I just removed the * after #appUserStatTbl

Thanks

Diego






On Fri, Aug 26, 2016 at 4:58 AM, Maciej Bąk <maciej...@gmail.com> wrote:
I tried also "#appUserStatTbl *" #> (1.to(114).map(num => ".position *" #> num.toString)) but crap it renders table 114 times :(


W dniu piątek, 26 sierpnia 2016 08:46:00 UTC+2 użytkownik Maciej Bąk napisał:
HI,

Im rendering quite big table ( over 100 positions ). 
In each I have <td class="position"></td>
Is it possible to somehow make working : 
(1.to(114).map(num => ".position" #> num)) ?

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Juan Jose Olivera

unread,
Aug 26, 2016, 8:06:19 AM8/26/16
to lif...@googlegroups.com
Try this

def renderNums = "#appUserStatTbl" #> (1.to(114).map(num => ".position *" #> num.toString))
def sendSnapshot(): Unit = {
val html = Templates("admin" :: "app" :: "statistics" :: Nil).getOrElse(<span>Template Not found</span>)
val out = (renderNums(Statistics.listStatistics(html))).toString

<div class="l:Statistics.listStatistics">

<h3>User Statistics - <span name="generation-date">Date and Time</span></h3>

<center>
        <table class="tablesorter" style="width: 80%" border="1" >

<thead>
<tr>
<th>Position</th>
<th>Statistic</th>
<th>Value</th>
</tr>
</thead>
<tbody>
            <tr id="appUserStatTbl" >
                <td class="position"></td>


To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Juan Jose Olivera Rodriguez
Genso Iniciativas Web
+591.44505438

Maciej Bąk

unread,
Aug 26, 2016, 8:15:53 AM8/26/16
to Lift
But heh, look at html ;]

<table id="appUserStatTbl" class="tablesorter" style="width: 80%" border="1" >
<thead>
<tr>
<th>Position</th>
<th>Statistic</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td class="position"></td>
        <td>A</td>
<td class="l-static-growth-rate"></td>
</tr>

<tr>
<td class="position"></td>
        <td>B</td>
<td class="l-mua"></td>
</tr>

<tr>
<td class="position"></td>
        <td>C</td>
<td class="l-wua"></td>
</tr>

Diego Medina

unread,
Aug 26, 2016, 12:03:56 PM8/26/16
to Lift
ok, now that I see your html, have a question, do you want the row with A to have a cell 1, row B to have cell 2, etc? so, can I just ignore the two rows after the first one? or do you need the group of 3 rows to repeat?

To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Diego Medina

unread,
Aug 26, 2016, 12:10:10 PM8/26/16
to Lift
scala> import xml.NodeSeq
import xml.NodeSeq

scala> import net.liftweb.util.Helpers._
import net.liftweb.util.Helpers._

scala> 

scala> val x = <table id="appUserStatTbl" class="tablesorter" style="width: 80%" border="1" >
     |     <tbody>
     |     <tr>
     |         <td class="position"></td>
     |         <td>A</td>
     |         <td class="l-static-growth-rate"></td>
     |     </tr>
     |     </tbody>
     |     </table>
x: scala.xml.Elem =
<table id="appUserStatTbl" class="tablesorter" style="width: 80%" border="1">
    <tbody>
    <tr>
        <td class="position"></td>
        <td>A</td>
        <td class="l-static-growth-rate"></td>
    </tr>
    </tbody>
    </table>

scala> 

scala> def css = "#appUserStatTbl ^^" #> "ignored" & "tr" #> 1.to(114).map { row =>   ".position *" #> row  }
css: net.liftweb.util.CssSel

scala> css(x)
res4: scala.xml.NodeSeq =
NodeSeq(<table id="appUserStatTbl" class="tablesorter" style="width: 80%" border="1">
    <tbody>
    <tr>
        <td class="position">1</td>
        <td>A</td>
        <td class="l-static-growth-rate"></td>
    </tr><tr>
        <td class="position">2</td>
        <td>A</td>
        <td class="l-static-growth-rate"></td>
    </tr><tr>
        <td class="position">3</td>
        <td>A</td>
        <td class="l-static-growth-rate"></td>
    </tr><tr>
        <td class="position">4</td>
        <td>A</td>
        <td class="l-static-growth-rate"></td>
    </tr><tr>
        <td class="position">5</td>
        <td>A</td>
        <td class="l-static-growth-rate"></td>
    </tr><tr>
        <td class="position">6</td>
        <td>A</td>
        <td class="l-static-g...
scala> 



appUserStatTbl ^^   makes the next selector start just after it, ignoring if there are other tr anywhere on your page inside this snippet scope



Maciej Bąk

unread,
Aug 29, 2016, 3:33:56 AM8/29/16
to Lift
Eh thanks for help :) But it just copies it 114 times..
Look in my example I have 114 diffenr positions, whhich I first render with proper values, then I want to numerate them..


W dniu piątek, 26 sierpnia 2016 08:46:00 UTC+2 użytkownik Maciej Bąk napisał:

Maciej Bąk

unread,
Aug 29, 2016, 7:34:17 AM8/29/16
to Lift
Ah well, Ive changed solution completly finally. 
Im putting tr values from scala code, this solution is ok to numerate everything well + its easier to test it later :)
Reply all
Reply to author
Forward
0 new messages