Home » Community » Newbie corner » SqlArray: Option widget linked to a referenced field
SqlArray: Option widget linked to a referenced field [message #51430] |
Mon, 25 March 2019 11:22 |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
Hi there,
I have a table ("rawmaterial") on a database containing data on raw materials stocked in a warehouse. The RDBMS is PostgreSql. The table is shown to the user with a SqlArray. It has some boolean fields that I like to show with an Option widget. The code is the following and it works fine:
myTbl.AddColumn(ISBULK, "Bulk", 4).With(
[](One<Ctrl>& x) {
x.Create<Option>().SetEditable(false);
}
);
This table should also shows the user if the raw material is out of stock. This piece of information is not stored directly in the rawmaterial table: it has to be computed calculating how much of the material has been consumed. That is referenced in another table, so I setup a converter that queries the other table and returns a boolean value. I show this in the SqlArray with a standard control (the resut is either 0 or 1 depending if the material is available or is in out of stock):
myTbl.AddColumn(ID,"Stockout",3).SetConvert(Single<ConvertStockOut>());
As I said, this works: the SqlArray column is linked to the ID of the raw material, then the converter is in charge to convert the ID to a boolean value.
I thought that it would be nice to show also that in an Option widget, so I modified the code as follows:
//The following code does not work as expected
myTbl.AddColumn(ID,"Stockout",3).SetConvert(Single<ConvertStockOut>()).With(
[](One<Ctrl>& x) {
x.Create<Option>().SetEditable(false);
}
);
But the code does not work as expected. It shows always a true value. As far as I understood, the SqlArray "passes" the value to the control, the control shows it on screen, and after that the converter converts the value in the desired form. This does not work in my case, because the Option widget does not understand a value greater than 1, so it fails.
Is there a way to solve my issue?
Regards,
Gio
|
|
|
Goto Forum:
Current Time: Fri Sep 20 05:31:31 CEST 2024
Total time taken to generate the page: 0.04905 seconds
|