Topic: auto load tabelgrid data from mysql
i have programmed MVD with MySQL connection and web interface
i want to know how can the table grid autoload from the database when someone adds a new entry to the web interface
My Visual Database → General → auto load tabelgrid data from mysql
i have programmed MVD with MySQL connection and web interface
i want to know how can the table grid autoload from the database when someone adds a new entry to the web interface
i have programmed MVD with MySQL connection and web interface
i want to know how can the table grid autoload from the database when someone adds a new entry to the web interface
I think it is better to just put a button and manually update the grid
e.g.
Form1.Tablegrid1.dbUpdate;
I got some idea on how to make it auto-reload but it's kind of messy.
If you know trigger in MySQL, then you can use it to update a table (`settings` maybe) that will increment if a user add, update or delete a record in a table, then you can have a loop in script that will check on that table.
On load of your system, store that `setting` value in a global variable or store it in the refresh button's tag, etc, your choice. then if the data from database changes or not same with the data in your variable/button's tag, reload the grid.
You have to consider traffic in your server though especially if you implement this with several tablegrids.
it works
is there any way to be executed automaticlmy
var
timer:TTimer;
procedure Form1_OnShow (Sender: TObject; Action: string);
begin
timer:=TTimer.Create(Form1);
timer.Interval:=1000; //1000 for 1 sec
timer.Enabled:=True;
timer.OnTimer:=@updateGrid;
end;
procedure updateGrid ;
begin
Form1.TableGrid1.dbUpdate;
end;
Try blackpearl's example. Just add a condition before updating the grid. It'll be a bad experience for the user when navigating the grid if you reload it. unless your grid is only for viewing.
procedure updateGrid ;
begin
if not Form1.TableGrid1.Focused then
Form1.TableGrid1.dbUpdate;
end;
Then again, you have to consider the traffic, If you are accessing database online, then there's a drawback. It will continuously sending a request. Trap it If your grid is accessed in a popup or not in the main form by adding another condition
procedure updateGrid ;
begin
if ((not Form1.TableGrid1.Focused) AND (Form1.Visible)) then
Form1.TableGrid1.dbUpdate;
end;
My Visual Database → General → auto load tabelgrid data from mysql
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi