Recent

Author Topic: [SOLVED] How to refresh a record in a Grid?  (Read 2393 times)

socger

  • Newbie
  • Posts: 3
[SOLVED] How to refresh a record in a Grid?
« on: December 04, 2014, 09:59:28 am »
In a SELECT to MySQl i use 3 tables with LEFT JOIN in two of them.

When on the component SQLQuery make a APPEND or INSERT (even in an EDIT) and then do the ApplyUpdate, the fields that they are not of primary tables ( LEFT JOIN), won't be refresh.

I've solved returning to do the SELECT and going on the record with a LOCATE. But this means bringing back all the records in the SELECT.

So the question is, is there another way to just refresh the record that I just created or modified?.

Forgive my translation with Google. Greetings and thank you very much.
« Last Edit: December 05, 2014, 12:37:43 pm by socger »

exdatis

  • Hero Member
  • *****
  • Posts: 668
    • exdatis
Re: How to refresh a record in a Grid?
« Reply #1 on: December 04, 2014, 10:08:47 am »
Something like...
Save position eg.
const
  yourIdKey : String = 'yourFieldName';
var
  currPosition : Integer;
begin
  currPosition:= yourDataSet.FieldByName(yourIdKey).AsInteger;
  yourDataSet.DisableControls;
  try
    yourDataSet.Refresh.
    yourDataSet.Locate(yourIdKey, currPosition, []);
 finally
    yourDataSet.EnableControls;
 end;
« Last Edit: December 05, 2014, 08:03:55 am by exdatis »

socger

  • Newbie
  • Posts: 3
Re: How to refresh a record in a Grid?
« Reply #2 on: December 04, 2014, 10:29:43 am »
Yes i did something like it.

But i want only to refresh the record that was insert or edit, but without loose the rest of records.

Thank you, for your help my teacher.
« Last Edit: December 04, 2014, 10:31:58 am by socger »

kapibara

  • Hero Member
  • *****
  • Posts: 511
Re: How to refresh a record in a Grid?
« Reply #3 on: December 05, 2014, 05:23:56 am »
I dont think you can refresh just one record. But does it matter? Take a look at the query's property PacketRecords. Its 10 by default and thats how many records that will be retrieved from the table at once. So maybe you can just go with that.

Yes i did something like it.

But i want only to refresh the record that was insert or edit, but without loose the rest of records.

Thank you, for your help my teacher.
Lazarus trunk / fpc 3.0.4 / Debian Stretch 64-bit

socger

  • Newbie
  • Posts: 3
Re: How to refresh a record in a Grid?
« Reply #4 on: December 05, 2014, 12:37:15 pm »
OK, THANK YOU