Just wanted to ask to get some design feedback on the system. I have a set of custom properties on a view, but they are null until an operator selects a row in the table. In the browser, they seem to work fine, but in the designer, it shows an error for each one.
Is this an ok practice? Should I put a transform in to convert the null values? The properties won’t be pulled for anything unless a row is selected, so I don’t think I’ll have issues with processing those values within my scripts. Just don’t want to break or hurt anything elsewhere.
The warning is actually a result of the bindings you have in place, not the null values.
As for whether or not it’s an acceptable practice… Yes and no, but generally no.
Yes:
Your View should work, though values which are bound against these values could cause problems (how does a Table represent null data?). This is why they are only warnings, and not error dialogs.
No:
The warnings only tell you that something is wrong, not what “type” of wrong it is. If one of those is throwing a warning because a property isn’t found (self.props.non_existent_property) and that property is referenced at runtime, then you won’t see any changes.
If the warning is failing due to a NamedQuery that had its name changed and you’re used to always seeing the warning, will you ever notice that the query’s name has changed and attempt to fix the binding? Probably not, because you’re always going to think “Oh, yeah, that’s always like that.”
Instead of having one object with nine bindings, just bind against Table.props.selection.data wherever you would use that data, and extract the data you need from the returned object.
In your use case, you are duplicating an object which already exists, and binding (I’m assuming columns) to object keys, when you could just bind to the original object and grab what you need piece-meal.
Wrapping the bindings with a transform which returns null if nothing is found will work, but it will also mask failing bindings, as that failure will be transformed to null. Binding against Table.props.selection.data and using a script or expression Transform to obtain the necessary data would give you the option to handle the empty array without having to implement a
if value['Desc'] is None:
return None # or "" or whatever handling you prefer
For a Table column defined as “ColumnA”, the following Script transform on a binding of ../Table.props.selection.data got me the selected row’s value in the "ColumnA’ column:
if len(value) > 0:
return value[0]['ColumnA']
return ''
Using this method will display no warnings in the Designer, and if a specific binding does fail, you’ll notice it at the individual component level, as opposed to some obscure property hidden within a component, but which affects MANY components.