How to set the label for the items in a ListWithDetail

Hi all,

How do I control which property will be used as the label of each item in a ListWithDetail? My best guess is that it uses the property that comes first alphabetically, but I was hoping there was some way to specify a particular property. Here’s a screenshot that illustrates the issue:

(I’m hoping to use the value for “Folder” for the label, instead of the value for “Filename”, as is happening in the screenshot.)

Hi @brockfanning,

it uses the value of the first primitive property (i.e. its type in the schema is string, number or integer) defined in the schema. Thereby, the property names are not sorted but considered in definition order in the schema. For reference, the labels are extracted here in the JsonForms code: https://github.com/eclipsesource/jsonforms/blob/28eeeca537ef1a38e44de12cd9e6f5d5632cb913/packages/core/src/util/renderer.ts#L655-L664

Unfortunately, this is currently not customizable in the default renderer. In your case, defining the folder property before the file name property in the schema should do the trick.

Best regards,
Lucas

I thought the labelRef option is meant to solve that issue?

Hi @hellsfantasy ,
thanks for the hint. I quickly checked again and the labelRef property can indeed be used in the angular MasterListComponent. However, it does not seem to be applied by the material list with detail renderer. At least I could not see it being used in the code.

1 Like