Topic: refresh time for table grid?

Hello,

when I start my app on several Workstations I can see only "my" entries in the grid. Only when I close, restart or make a new entry, the grid gets an update and I can see the changes from the other workstation.
Is it possible to set an interval which update the grid automatically? So every 5 seconds the grid gets an update and all open sessions can see the current entries?

Thanks for any hint.

cheers

gieri

Re: refresh time for table grid?

Hello,


An example for you

Post's attachments

Attachment icon Employees refresh by timer.zip 6.75 kb, 234 downloads since 2016-07-19 

Dmitry.

Re: refresh time for table grid?

Hello Dimitry,

thanks for the sample. In fact of I don´t have any clue how to work with scripts, I don´t know if I can add you code to my existing code which I need to get a multiselction of the rows.

Current it looks like this:

procedure Form1_Button3_OnClick (Sender: string; var Cancel: boolean);
var
   i,c: integer;
   iColumn: integer;
begin
   iColumn := Form1.tablegrid1.Columns.Count-1; // in last column stored id of record (last column hided)
   c := Form1.tablegrid1.RowCount - 1; // count of records in TableGrid
   for i :=0 to c do
     if Form1.tablegrid1.Selected[i] then // if record selected
        SQLExecute('DELETE FROM retoure WHERE id = ' + Form1.tablegrid1.Cells[iColumn, i]); // SQL query for selected record
   form1.tablegrid1.dbUpdate;
end;

begin
   form1.TableGrid1.Options := form1.TableGrid1.Options + goMultiSelect;
end.

var
   Timer: TTimer;

procedure Form1_OnShow (Sender: string; Action: string);
begin
     Timer := TTimer.Create (nil);
     Timer.OnTimer := @OnTimer;
     Timer.Interval := 5000; // every 5 sec
     Timer.Enabled := True;

end;

procedure OnTimer;
begin
     Form1.tablegrid1.dbUpdate;
end;

procedure Form1_OnClose (Sender: string; Action: string);
begin
     Timer.Free;
end;

but it doesn´t work.

What have I made wrong here?

cheers

gieri

Re: refresh time for table grid?

gieri
Please attach your project. Zip file without exe and dll files.

Dmitry.

Re: refresh time for table grid?

DriveSoft wrote:

gieri
Please attach your project. Zip file without exe and dll files.

see attached..

cheers

gieri

Post's attachments

Attachment icon Projektdatei.rar 6.31 kb, 220 downloads since 2016-07-19 

Re: refresh time for table grid?

I'm not a coder myself so I would love to see if this works. God speed @Drivesoft smile

Re: refresh time for table grid?

gieri
Please download fixed project

Post's attachments

Attachment icon Retoure_Projektdatei_fixed.zip 8.46 kb, 247 downloads since 2016-07-20 

Dmitry.

Re: refresh time for table grid?

Hello Dmitry,

thanks for the file. The refresh works now very good. Regrettably after a refresh, the table focus jumps to the first entry.
So if you have for example 50 entries, after 5 second the table view jumps to the first.

Is there any chance to fix this?

cheers

gieri

Re: refresh time for table grid?

gieri wrote:

Hello Dmitry,

thanks for the file. The refresh works now very good. Regrettably after a refresh, the table focus jumps to the first entry.
So if you have for example 50 entries, after 5 second the table view jumps to the first.

Is there any chance to fix this?

cheers

gieri

Hello,


Please download latest beta version 2.7
https://www.dropbox.com/s/582unbatehan1 … a.zip?dl=0


Then change this code

procedure OnTimer;
begin
     Form1.tablegrid1.dbUpdate;
end;

to

procedure OnTimer;
var
    id: integer;
begin
     id := Form1.TableGrid1.VertScrollBar.Position;
     Form1.tablegrid1.dbUpdate;
     Form1.tablegrid1.VertScrollBar.Position := id;
end;
Dmitry.

Re: refresh time for table grid?

Hello Dmitry,

thanks for your help. Now it works very good!

Have a nice weekend ;-)

Cheers

gieri

Re: refresh time for table grid?

Hello Dmitry,

just have a quick question how to get the update thing to the other tablegrid in my DB?
The scriptcode just have TableGrid1, but I have the other Grid with TableGrid2 in the same window. Is it possible to update both grids at the same time?

Cheers

gieri

Re: refresh time for table grid?

gieri wrote:

Hello Dmitry,

just have a quick question how to get the update thing to the other tablegrid in my DB?
The scriptcode just have TableGrid1, but I have the other Grid with TableGrid2 in the same window. Is it possible to update both grids at the same time?

Cheers

gieri

Change this code

procedure OnTimer;
var
    id: integer;
begin
     id := Form1.TableGrid1.VertScrollBar.Position;
     Form1.tablegrid1.dbUpdate;
     Form1.tablegrid1.VertScrollBar.Position := id;
end;

To

procedure OnTimer;
var
    id1, id2: integer;
begin
     id1 := Form1.TableGrid1.VertScrollBar.Position;
     Form1.tablegrid1.dbUpdate;
     Form1.tablegrid1.VertScrollBar.Position := id1;

     id2 := Form1.TableGrid2.VertScrollBar.Position;
     Form1.tablegrid2.dbUpdate;
     Form1.tablegrid2.VertScrollBar.Position := id2;
end;
Dmitry.

Re: refresh time for table grid?

many Thanks. Works 100%

cheers

gieri

Re: refresh time for table grid?

Hello Dmitry,

sorry, just still have a little issue :-(
I display not all Columns in my TableGrid1 (above) and sort the grid Descending on the column ".added".

On the first start of the app, everything looks good. When I make a Mouse click into the TableGrid2 (below). The TableGrid1 is mixed up, lose the sorting and all hided Columns are displayed. How can I fix this?

Also the Column width is lost very often. Is there a parameter where I can make the Column width fix?

Project zip attached.

Cheers

gieri

Post's attachments

Attachment icon Projektdatei.zip 8.72 kb, 194 downloads since 2016-08-01 

Re: refresh time for table grid?

gieri

Please download latest beta version 2.7 here:
https://www.dropbox.com/s/582unbatehan1 … a.zip?dl=0


Then check out attached project:

Post's attachments

Attachment icon Projektdatei_fixed.zip 10.79 kb, 220 downloads since 2016-08-02 

Dmitry.

Re: refresh time for table grid?

Hi Dmitry,

thanks for the sample. Regrettably the problem still exist. When i click after the first start into the TabelGrid2 ... the Columns of TableGrid1 will rearranged similar to TableGrid2.

Cheers

gieri

Re: refresh time for table grid?

Hello Dmitry,

found out that the TabelGrid1  also lost its column order when I type something into the search. Suddenly all Columns are shown.

Cheers

gieri

Re: refresh time for table grid?

gieri wrote:

Hello Dmitry,

found out that the TabelGrid1  also lost its column order when I type something into the search. Suddenly all Columns are shown.

Cheers

gieri

Order of column adjustment in the settings of button with action "Search"

Dmitry.

Re: refresh time for table grid?

Hello Dmitry,

thanks for that hint. Now the search problem is fixed. How about the TableGrid behavior? Do you have a solution for that?

Cheers
gieri

Re: refresh time for table grid?

Hello Dmitry,

also another behavior which I can´t solve.
When I search something, the Search is  configured that both Grids are involved. But when I search something, the TableGrid2 gets no hit but the content is there.

Also the sort in TableGrid2 get lost after a few seconds. I sort by Name (click on the column head) and after 3 Seconds the list is mixed up

Cheers

gieri

Re: refresh time for table grid?

Hi Dmitry,

did you have a solution to solve my last two problems?

Thanks for any respons.


Cheers

gieri

Re: refresh time for table grid?

gieri wrote:

Hi Dmitry,

did you have a solution to solve my last two problems?

Thanks for any respons.


Cheers

gieri

Hello,


I tried, but unfortunately can't find solution.
Sorry for inconvenience.

Dmitry.

Re: refresh time for table grid?

Unfortunately you use pirate version of software. Support on the forum only for legal users.

Dmitry.