I
I
Ivan Balan2014-03-18 01:50:16
SQL
Ivan Balan, 2014-03-18 01:50:16

How to edit joined fields in one DbGrid?

There are 3 tables:
-Foods
-Ingredients -Link
The
table of dishes and ingredients is connected Many-to-Many via the Link intermediate table.
Structure Foods:
fa5e2a5a4a974dfe9b150485b1aced94.png
Structure Ingredients:
be107440d6164406a85d4d1d16a38fa3.png
Structure Link:
e0c62adeb1414cc1ac3fadbf5efd6482.png
What's the idea: there is a list of dishes. Double-clicking opens a window with a list of ingredients, gross quantity and price. The name of the dish and the price come from Ingredients, and the gross quantity from Links. For ease of use, you need to edit directly in the cells of the table (in my case, cxGrid).
I pull out the data through Query with master-detail relations. How can I put data from two different datasets into 1 table and edit them there? In my case, I make a request with Left Join of the fields I need from the ingredients table, but they are not editable, only the fields that belong to Link are editable.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lacaille, 2014-03-18
@Toddams

Option 1. CxGrid allows you to conveniently edit related tables. The user on the desired dish presses "+" and edits the list of ingredients.
Option 2. You can add an UpdateSQL component and bind it to a DataSet.UpdateObject. In the UpdateSQL.ModifySQL property, write a request to change the record. The UpdateSQL component knows such a variable as OLD_<key name> by which you can access the desired field, an example query:

UPDATE <имя таблицы>
   SET <имя поля для изменения> = :<имя поля для изменения>
 WHERE <ключ таблицы> = :OLD_<ключ таблицы>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question