Hi everyone,
What is the best/easiest way to swap records in a TUniQuery, CachedUpdates=True, without commiting
to the sql server and keeping the modified values in the dataset?
Like you would move a position in a list up/down, but commiting the changes only by the user.
The list is shown in a 3rd party dbgrid.
Thx
Swapping rows
Re: Swapping rows
The question about how to swap records in grid is not related to UniDAC functionality, since the TUniQuery dataset can't manage visual controls behavior.
As a solution for the mentioned task, you can add a fake field into the SELECT query of the dataset, which will be responsible for record display order in the grid (SELECT ... , 0 as order_field). Specify this field name in the TUniQuery.IndexFieldNames property in order for the dataset to perform local sorting by this field. Set the TField.ReadOnly property of the field to False. And to swap records in the grid, modify the order_field field values for these records.
As a solution for the mentioned task, you can add a fake field into the SELECT query of the dataset, which will be responsible for record display order in the grid (SELECT ... , 0 as order_field). Specify this field name in the TUniQuery.IndexFieldNames property in order for the dataset to perform local sorting by this field. Set the TField.ReadOnly property of the field to False. And to swap records in the grid, modify the order_field field values for these records.
Re: Swapping rows
It has nothing to do with GUI.
The grid is just a reflection of the buffer.
You could expose ExchangePos or a similar function as public... there is no reason to hide this function.
The grid is just a reflection of the buffer.
You could expose ExchangePos or a similar function as public... there is no reason to hide this function.
Re: Swapping rows
There is not the ExchangePos function in UniDAC - you can implement it by yourself using the proposed method or another one.