edit single property in a table view

Hi,

I want change a specific property of specific field in a row of table, but I have some records in this table and when I change a property for a specific field this property change the value in every fields in that column.
I think servoy give a ID unique for every fields but I don’t know how obtain that ID.

Anyone can help me?

Thanks in advance.

You are talking about a table view, right?

If you want to change a property only for certain rows, you can use the onRender event, for example to set the background color of orders depending on the is_paid field:

function onRender(event) {
   /** @type {JSRecord<db:/example_data/orders>} */
   var _orderRec = event.getRecord();
   var _element = event.getRenderable();
   
   if (_orderRec && _orderRec.is_paid) {
      _element.bgcolor = "#00ff00";
   } else {
      _element.bgcolor = "#ff0000";
   }
}

Joas:
You are talking about a table view, right?

If you want to change a property only for certain rows, you can use the onRender event, for example to set the background color of orders depending on the is_paid field:

function onRender(event) {

/** @type {JSRecorddb:/example_data/orders} */
var _orderRec = event.getRecord();
var _element = event.getRenderable();

if (_orderRec && _orderRec.is_paid) {
_element.bgcolor = “#00ff00”;
} else {
_element.bgcolor = “#ff0000”;
}
}

Thanks for the reply, but isn’t this what I want to do.
I want to change a background color of button when i click it and if I use the code:

forms.indirizzi_tbl.elements.Principale.bgcolor="#009900";

change backgroud color of the all button in the table.

As far as I can tell there’s no way you can individually change properties of elements (of different rows) in a table view. But the onRender method could actually give you a hand. You could try to change the property you need based on some value you can read from the record you retrieve from the JSRender event.

davide.bovio:
As far as I can tell there’s no way you can individually change properties of elements (of different rows) in a table view. But the onRender method could actually give you a hand. You could try to change the property you need based on some value you can read from the record you retrieve from the JSRender event.

Are you sure? Isn’t there a trick to do this?

The onRender is the way to go here.

What you could do is save the pk of the record in a form variable when you click the button. Then let the onRender color the element on the record with that pk.

Joas:
The onRender is the way to go here.

What you could do is save the pk of the record in a form variable when you click the button. Then let the onRender color the element on the record with that pk.

Use the pk and the event onRender I have resolv my issue. I want to change the caption/text of button but I’m not able.
Thanks for help, someone else has other ideas?

Do I understand correctly that you CAN change the bgcolor of the button for one row, but NOT the text? It should work the same for all properties.

What does your onRender method look like?

Joas:
Do I understand correctly that you CAN change the bgcolor of the button for one row, but NOT the text? It should work the same for all properties.

What does your onRender method look like?

When I click on the button i can change the bgcolor of the button and the frcolor of button but not the text.
Probably I’m wrong, but now I’ve modify my solution and this problem is disappeared.