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

31 views Asked by At

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.

1

There are 1 answers

1
Dave Whittaker On BEST ANSWER

Each Field has a name that is unique within the Record

jobs map { j => 
  fieldsToDisplay map { f => 
    j.fieldByName(f.name) 
  } 
}