Suppose I have a data source for products that has the field supplier_id. When opening the form for an existing product, I want to see the name of the supplier. I want to send this name from the server together with this ID (so that no extra query is necessary to retrieve the supplier). Therefore I use a SQL statement like this:
To change the supplier, I show a combo box and only then a query needs to be done to retrieve the suppliers. On the server it should be a SQL like:
I was hoping to be able to do something like this (like in a ListGrid):
And then I need to specify different values for displayField and valueField when the combo box is pressed.
I don't think this is possible, so I'm looking for a suitable "work-around" / solution. I've also tried to do something with setting the foreignKey property on the supplier_id field in the data source of products. This causes an extra query, which is not that big of a deal, but I have an extra issue there. In reality all my records have a field "shop_code" indicating the shop the product belongs to (so one database is used for multiple shops). So when retrieving the supplier, it also needs to send the shop_code of the product (which is the same). My SQL statement in fact needs to be something like this:
I don't know where or when to specify this extra request parameter (if possible at all). It basically means I have a composed foreign key relation and reading the Quick Start Guide gives me the feeling this is not possible.
Code:
SELECT products.id, products.supplier_id, suppliers.name AS supplier_name FROM products INNER JOIN suppliers ON suppliers.id = products.supplier_id
Code:
SELECT id, name FROM suppliers
Code:
isc.DynamicForm.create({ fields: [ { name: 'supplier_id', displayField: 'supplier_name' } ] });
I don't think this is possible, so I'm looking for a suitable "work-around" / solution. I've also tried to do something with setting the foreignKey property on the supplier_id field in the data source of products. This causes an extra query, which is not that big of a deal, but I have an extra issue there. In reality all my records have a field "shop_code" indicating the shop the product belongs to (so one database is used for multiple shops). So when retrieving the supplier, it also needs to send the shop_code of the product (which is the same). My SQL statement in fact needs to be something like this:
Code:
SELECT products.id, products.supplier_id, suppliers.name AS supplier_name FROM products INNER JOIN suppliers ON suppliers.id = products.supplier_id AND suppliers.shop_code = products.shop_code
Comment