Editable table from a mongo record

Showing 1-1 of 1 messages
Editable table from a mongo record AlexVM 10/13/12 11:27 AM

I want to implement a fairly simple, editable table from a mongo record. The table will use ajaxEditable to make each cell editable. I'm just looking for a bit of advice from this community as to how this should be structured. I would like to apply this to other mongo records in the future so it needs to be fairly extensible.

My current record looks like:

class Part extends MongoRecord[Part] with ObjectIdPk[Part] {
  def meta = Part

  object customer extends StringField(this, "")
  object part_number extends StringField(this, "")
  object base extends StringField(this, "")
  object base_color extends StringField(this, "")
  object description extends StringField(this, "")

object Part extends Part with MongoMetaRecord[Part] 

I would want something that could:

1) Take a map of table headings and the corresponding field e.g. Map("Customer" -> customer, "Part Number" -> part_number) - this would describe what fields will be in the table as well as a heading for each.
2) A method that generates the table heading <thead> element (based of the Map in (1) )
3) A method that generates the table rows, the values of which would be from a Part record.

 My question is what would be the best design pattern to achieve this? I could create a trait that extends MongoMetaRecord that contains the map and a static method to process a list of Part records into table elements but this doesn't seem optimum.