Answer the question
In order to leave comments, you need to log in
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:
Structure Ingredients:
Structure Link:
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
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 questionAsk a Question
731 491 924 answers to any question