Selection field of concatenated data?
Selection field of concatenated data?
In the table view I have a field displayed that is concatenated from other table join fields.
columns: [
{ //display of foreign key fkunit, display as "Unit Type # [District Name]", allow filtering of each element
label: 'unit',
render: function (data, type, row) {
return row.tblunittype.unittype + ' ' + row.tblunit.unitnumber + ' [' + row.tbldistricts.districtname + ']'
}
},
How do I provide this list as the items in dropdown when editing?
fields: [
{ //reference foreign key fkunit, display as "Unit Type # [District Name]",
label: 'Unit',
name: 'tblcamping.fkunit',
render: function (data, type, row) {
return tblunittype.unittype + ' ' + tblunit.unitnumber + ' [' + tbldistricts.districtname + ']'
},
type: 'select'
},
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
There is no
render
option for the Editor fields - so I'm afraid that won't work like that.I think the first thing we need to figure out is how you want this to be edited. Should the user edit all three values in a single field? If so then I would suggest using a get and set formatter at the server-side so the client-side only ever sees one value (i.e. the server will concatenate the values on get and split them on set).
If the user should be setting each value individually then simply have three fields - one for each.
Allan
the concatenated field is the display for the foreign key of tblcamping.fkunit. The tblunit table which contains the unit number and contains 2 foreign keys, fkdistrict and fkunittype which reference the join tables districts and unittype.
returns:
Which I'd like the user to select from a dropdown :
Upon selection, the id is inserted into the tblcamping.fkunit field.
edited by allan Code highlighting
Thanks for the clarification.
To show the list of options you'll want to use a the more advanced options for the
Field->Options()
method (specifically look at the last example in the "Parameters - easy database options" part).Allan
got it to work.