Page 1 of 1

Setting properties on a widget within a grid

Posted: Thu Nov 18, 2021 9:19 am
by RichDotsonMTD
I wrote a javascript function that allows us to hide or disable widgets or tabs on any UI by placing the id name of the widget (and other key fields) in a table on the iSeries. This function is called in the onLoad() event for the record format. I use the applyProperty() function for the widgets and the getObj("tabname").hideTab() function for the tabs. This is working great.

The issue I cannot figure out is how can I use JavaScript to hide/disable widgets that are defined within a grid? My plan was to retrieve the number of rows in the grid and then loop through the rows and hide/disable the widget but I cannot find a function that will allow me to apply a property to a widget within a grid. I saw a method [getObj("Grid1").grid.getDataValue(1, "CUSTID")] that retrieves the data but nothing that allows me to set the properties.

Is there a function that will allow me to do this or some other way to do this?

Thanks,
-Rich

Re: Setting properties on a widget within a grid

Posted: Thu Nov 18, 2021 1:04 pm
by Scott Klement
When Profound UI generates widgets in a grid, it adds a suffix to the "id" property for each row. For example, if you have an output field in a grid, and you set it's ID property to "myOutputField", then in row 1 of the grid, the ID will be "myOutputField.1", and in row 2 it will be "myOutputField.2", etc.

You can use those IDs with the applyProperty() function.

Code: Select all

applyProperty("myOutputField.2", "visibility", "hidden");
or perhaps

Code: Select all

for (var i=1; i=<numberOfRows; i++) {
  applyProperty("myOutputField." + i, "visibility", "hidden");
}
There is a caveat to this, however: For performance reasons, the widgets in a grid are not created until the user pages the row onto the screen. Therefore, if you tried to loop through all rows, and some have never been displayed to the user, some of the widgets may not exist, yet.