Page 1 of 1
Swapping rows
Posted: Tue 23 Feb 2016 12:05
by Atys
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
Re: Swapping rows
Posted: Fri 26 Feb 2016 10:40
by azyk
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.
Re: Swapping rows
Posted: Wed 07 Jun 2017 23:43
by Atys
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.
Re: Swapping rows
Posted: Mon 12 Jun 2017 12:36
by azyk
There is not the ExchangePos function in UniDAC - you can implement it by yourself using the proposed method or another one.