Given a Field and a Record, how to obtain the value of that Field within that Record?

StackOverflow https://stackoverflow.com/questions/21583846

  •  07-10-2022
  •  | 
  •  

Question

I have something like:

val jobs = Job.where(...).fetch()
val fieldsToDisplay = Seq(Job.status, Job._id, ...)
val header = fieldsToDisplay map { _.name }
val tbl = jobs map { j => fieldsToDisplay map { _.getValueIn(j) } }
renderTable(header, tbl)

...and it's that hypothetical getValueIn I'm looking for.

I've been unable to find anything, but perhaps more experienced Lift'ers know a trick.

Was it helpful?

Solution

Each Field has a name that is unique within the Record

jobs map { j => 
  fieldsToDisplay map { f => 
    j.fieldByName(f.name) 
  } 
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top