Data Detail - possible to change the dynamic source based on a condition?

Hey all,

I have a data detail that shows data from a repeat.
Some of these repeats will have missing values (on purpose).

What I’d like to do - is when a BS5 canvass is opened, check for a value in the data and if it exists do nothing, if it doesn’t exist change the data source of the data detail.

I’ve tried simple changing the values of a variable between the two different data sources but that didn’t work.

I have also tried using a terniary in the dmx-bind:data="" section for the data source of the data detail with no luck, e.g.:

dmx-bind:data="fieldvalue ? 'datasource1' : 'datasource2'"

Appreciate any ideas here!

Not sure if this would work, but I think that I would do a what-if on the server.

  1. query the database table (no output)
  2. if value exits then output
  3. if not then output

Thanks for the reply Ben,

I should have been more explicit - the repeat has all the data we want to display in the data detail, to avoid having to call the server again which I see as the main benefit of using data detail - so I’m trying to avoid that in most cases.

I believe I’ve solved it, 99% there. Will share the approach and code below in case anyone finds value in it, or can improve the approach:

  1. I’ve created a variable, who’s purpose is to handle a 0 or a 1 value.
  2. I created a SC that calls a single record from the DB with all data I need, including the missing data.
  3. In the repeat, I have two identical buttons. One for when the field value is present, and one for when the field value is not present. One sets the var to 1. The other sets the var to 0, calls the SC and sends that repeats id to get info from the DB. Each button after the initial actions then open the canvass.
  4. In the dynamic binding for the data detail source I then have this terniary:

dmx-bind:data="(var_dd_source.value == 1) ? get_records.data.repeat1 : single_record.data.repeat)

Within my canvass I have a number of repeats, so it was also important for this to work for me that I recreated the same structure for both data sources in SC, ensuring that it reads/displays the same.