Selected row centers itself after query refresh
Selected row centers itself after query refresh
Hello,
I have a small software that uses a dbgrid. The problem is that when we refresh our MSQuery with the help of a MSChangeNotification the row that is currently selected in the dbgrid is centered if possible. This can be a bit annoying when we are scrolling down with the arrow keys, and that the db is updated every second or so. Is there a way to not center the active row? (Before SDAC we used FireDAC and the problem was not present, so it's probably not the grid's fault)
Thanks
I have a small software that uses a dbgrid. The problem is that when we refresh our MSQuery with the help of a MSChangeNotification the row that is currently selected in the dbgrid is centered if possible. This can be a bit annoying when we are scrolling down with the arrow keys, and that the db is updated every second or so. Is there a way to not center the active row? (Before SDAC we used FireDAC and the problem was not present, so it's probably not the grid's fault)
Thanks
Re: Selected row centers itself after query refresh
In order for SDAC not to reopen dataset when receiving a notification, set TMSQuery.Options.ReflectChangeNotify to False. More details about ReflectChangeNotify in our online documentation: https://www.devart.com/sdac/docs/?devar ... notify.htm
You can refresh data in dataset without its reopening by calling the TMSQuery.RefreshQuick method: https://www.devart.com/sdac/docs/?devar ... olean).htm
You can refresh data in dataset without its reopening by calling the TMSQuery.RefreshQuick method: https://www.devart.com/sdac/docs/?devar ... olean).htm
Re: Selected row centers itself after query refresh
Firstly, thank you for the response.
I tried with refresh quick but it only seems to work once. It's like if the query was not registered to be notified after the first refresh. In other words, my query update itself once and then it stops refreshing. Is there something you have to set for it to work, or is it because the query doesn't reopen?
Thank you again
I tried with refresh quick but it only seems to work once. It's like if the query was not registered to be notified after the first refresh. In other words, my query update itself once and then it stops refreshing. Is there something you have to set for it to work, or is it because the query doesn't reopen?
Thank you again
Re: Selected row centers itself after query refresh
As one of the task solutions, before opening dataset, execute the following code:
and in the TMSChangeNotification.OnChange event handler, call the Refresh method:
Code: Select all
MSQuery1.Options.NonBlocking := True;
MSQuery1.Options.ReflectChangeNotify := False;
MSQuery1.ReadOnly := False;
Code: Select all
procedure TMainForm.MSChangeNotification1Change(Sender: TObject;
DataSet: TCustomMSDataSet; NotificationInfo: TMSNotificationInfo;
NotificationSource: TMSNotificationSource;
NotificationType: TMSNotificationType);
begin
...
MSQuery1.Refresh;
Re: Selected row centers itself after query refresh
I just tried it and it still centers my active row.
Would it be possible to get an example of a working RefreshQuick?
Thank you
Would it be possible to get an example of a working RefreshQuick?
Thank you
Re: Selected row centers itself after query refresh
Please specify whether the specified issue is reproduced on our SDACDemo project. Use the solution from my previous post. SDACDemo project is located in the folder "Demos\SDacDemo\" relatively the path where SDAC demo projects were installed.
If the specified issue is not reproduced on SDACDemo, then compose a small test project to demonstrate it and to us via the contact form at our site: https://www.devart.com/company/contactform.html . Also include test DB backup(BAK) to the project.
If the specified issue is not reproduced on SDACDemo, then compose a small test project to demonstrate it and to us via the contact form at our site: https://www.devart.com/company/contactform.html . Also include test DB backup(BAK) to the project.
Re: Selected row centers itself after query refresh
I was able to reproduce the issue in the demo. I needed to had a bunch of data in the table so that the row could centers itself.
Here is how it looks before the update: https://imgur.com/SMY6Pqk
And here is the result after: https://imgur.com/a0MBwb9
Here is how it looks before the update: https://imgur.com/SMY6Pqk
And here is the result after: https://imgur.com/a0MBwb9
Re: Selected row centers itself after query refresh
We cannot affect the position of the active record in the grid when calling TMSQuery.Refresh/RefreshQuick, because SDAC datasets cannot control the behavior of the visual controls. To solve the issue, please read the documentation of the visual components that you are using either the specialized forums.