Topic: Refreshing records details

- When added new record I like to see tGrid focusing on newly added record and showing it's details on details section.
- When deleted an existing record  I like to see tGrid focusing on previous available records and showing it's details on details section.
- When edited (via button or double click) an existing record I like to see tGrid focusing on edited record and showing it's details on details section.
without the need of clicking on the record in tGrid.


Are these possible?


Please see the attached sample project to show if the items above are possible:

Post's attachments

Attachment icon Refreshing Records Details.zip 133.52 kb, 497 downloads since 2017-02-10 

Adam
God... please help me become the person my dog thinks I am.

Re: Refreshing records details

Solution for 1 section:
procedure frmCustomer_Button1_OnAfterClick (Sender: string);
begin
      Form1.tgSearch_Customers.dbItemID:= Last_Insert_id;
      Form1_tgSearch_Customers_OnCellClick('',0,0);
end;

Solution for 2 section:
procedure Form1_Button8_OnAfterClick (Sender: string);
var
i: integer;
begin
      i:= Form1.tgSearch_Customers.RowCount;
      Form1.tgSearch_Customers.SelectedRow:= i-1;
      Form1_tgSearch_Customers_OnCellClick('',0,0);
end;

Solution for 3 section is same as 1.

Re: Refreshing records details

bemorhona-qt wrote:

Solution for 1 section:
procedure frmCustomer_Button1_OnAfterClick (Sender: string);
begin
      Form1.tgSearch_Customers.dbItemID:= Last_Insert_id;
      Form1_tgSearch_Customers_OnCellClick('',0,0);
end;

Solution for 2 section:
procedure Form1_Button8_OnAfterClick (Sender: string);
var
i: integer;
begin
      i:= Form1.tgSearch_Customers.RowCount;
      Form1.tgSearch_Customers.SelectedRow:= i-1;
      Form1_tgSearch_Customers_OnCellClick('',0,0);
end;

Solution for 3 section is same as 1.


Tanks a lot bemorhona-qt....
It doesn't work at my end "not enough actual parameters..."
does it work at your end with the sample project posted on first post of this thread?

Adam
God... please help me become the person my dog thinks I am.

Re: Refreshing records details

AD1408 wrote:

Tanks a lot bemorhona-qt....
It doesn't work at my end "not enough actual parameters..."
does it work at your end with the sample project posted on first post of this thread?

Yes it does work. Take a look at the attached file.

Post's attachments

Attachment icon Refreshing Records Details.zip 134.3 kb, 520 downloads since 2017-02-11 

Re: Refreshing records details

Hi bemorhona-qt,


Yes, indeed your script does work..
Mistake was at my end, I have applied it to wrong form partially.


Thank you so much for your kind help..........

Adam
God... please help me become the person my dog thinks I am.

Re: Refreshing records details

Following refresh after add/edit/delete script returns - Undeclared identifier: "Form1_OnCellClick.."

procedure Form1_Button3_OnAfterClick (Sender: string);
var
i: integer;
begin
      i:= Form1.TableGrid1.RowCount;
      Form1.TableGrid1.SelectedRow:= i-1;
      Form1_TableGrid1_OnCellClick('',0,0);
end;

procedure frmAdd_Button1_OnAfterClick (Sender: string);
begin
      Form1.TableGrid1.dbItemID:= Last_Insert_id;
      Form1_TableGrid1_OnCellClick('',0,0);
end;

I have checked form, tGrid and buttons names... Cannot get rid off it.


bemorhona-qt's sample project fix works but this one is not. What am I missing???

Post's attachments

Attachment icon testing clear after delete etc2.zip 4.55 kb, 450 downloads since 2017-02-23 

Adam
God... please help me become the person my dog thinks I am.

7 (edited by AD1408 2017-02-24 01:37:05)

Re: Refreshing records details

AD1408 wrote:

Following refresh after add/edit/delete script returns - Undeclared identifier: "Form1_OnCellClick.."

procedure Form1_Button3_OnAfterClick (Sender: string);
var
i: integer;
begin
      i:= Form1.TableGrid1.RowCount;
      Form1.TableGrid1.SelectedRow:= i-1;
      Form1_TableGrid1_OnCellClick('',0,0);
end;

procedure frmAdd_Button1_OnAfterClick (Sender: string);
begin
      Form1.TableGrid1.dbItemID:= Last_Insert_id;
      Form1_TableGrid1_OnCellClick('',0,0);
end;

I have checked form, tGrid and buttons names... Cannot get rid off it.


bemorhona-qt's sample project fix works but this one is not. What am I missing???


As it was asking for onCellClick so I added an empty onCellClick procedure as below and naturally error disappeared:

procedure Form1_TableGrid1_OnCellClick (Sender: string; ACol, ARow: Integer);
begin
end;

procedure Form1_Button3_OnAfterClick (Sender: string);
var
i: integer;
begin
      i:= Form1.TableGrid1.RowCount;
      Form1.TableGrid1.SelectedRow:= i-1;
      Form1_TableGrid1_OnCellClick('',0,0);
end;

procedure frmAdd_Button1_OnAfterClick (Sender: string);
begin
      Form1.TableGrid1.dbItemID:= Last_Insert_id;
      Form1_TableGrid1_OnCellClick('',0,0);
end;

However, I'm not sure the above is correct way of doing this... Is it possible to put refresh script above under one procedure?

Adam
God... please help me become the person my dog thinks I am.