I have defined a custom property in a view (say taskdata) which I bind to an SQL Query returning a row from a database in a say [0x8] dataset for single row of data. Now I want to bind text property of 8 different labels on the view to the individual cells of the row dataset. How to do that?
The property binding shows that it is a dataset correctly, as shown in the image below, but how to access its individual cells while binding to label's text property? (I tried putting suffix [0,1] in obviously vain!)
When you get your query working, you can access a cell from a row quite easily with an expression binding: {view.custom.dataset}[x] where x is the 0-based index of the row.
Not really! Here is the binding without the index, which shows the result as a data set [0x8] However assigning index [1] to it gives binding error! - see second screen shot. I even tried [0,1] but same error
The table was empty though the headers are correctly filled. I found the problem; the query has an input field which comes from a parameter coming from the parent view of the view. Default value of this input field was left blank, so the query was returning null ! On giving an initial value it initializes the table and the binding to label text should work now! Thanks a lot all.
However the original question remains, when query return null, whats the best way to access the individual elements of the data set having null value!
My first problem is solved as explained above. It definitely executes the query for the first time while binding. However not sure when does it update by default when execution rate is not defined in the binding window. My guess is by default it will execute only when the view is loaded, unless specified an execution rate in the window in which it will execute periodically as you mentioned. Which makes sense actually.
It’s a very nice and more succint technique I learned from @pturmel. I use it a lot for add/edit windows. For a text box for instance, I put a custom property I tend to call initialValue and bind that to try({Root Container.initialData}[0, 'someColumn'], 'DEFAULT VALUE FOR CREATE'). Then I would bind my text property to the initialValue property and now I have set up the text box for loading a record and provided what should be in the text box for a new record in a single expression.
I didn’t ask my question right. I set the output as scalar, then it told me the output was null from the query. However, your answer got me the solution. if not value: