element control in list mode

I want a button enabled when there is a value in the database. I can do that for a form in record view.

if(value)
elements.test.enabled = true;
else
elements.test.enabled = false;

When the form is in list mode, than the button must be enabled or disabled for each record.
How can I achieve that?

Hi Leendert,

Short answer: you can’t.
What you could do however is use a calculation that shows a (button) image depending on the status.
And an onAction method on that calculation field that checks the record status and acts accordingly.

Hope this helps.

What you could do however is use a calculation that shows a (button) image depending on the status

How can I do that? Form access in a calculation isn’t possible.

Hi Leendert,

Like I said you can’t set a property of a button in a specific row. What you can do however is mimicking this behavior by using a calculation that shows an image depending on your status field (of that same record).
So you are not setting any form properties but you are showing an image (of a button) like so:

if (value) {
   return 'media:///button_enabled.png';
} else { 
   return 'media:///button_disabled.png';
}

You put this caculation on the list and add a method to the onAction event. This method will look something like this:

if ( value ) {
  // 'button' is enabled, do your thing
}

I know it’s a workaround but it does what you want to do.

I can’t get it to work. Do you show an image with the dataprovider that calculation?

That is correct. The field will be display type IMAGE_MEDIA.

Thanks, it works very nice.