Topic: Update 1 row in tablegrid after change

Hello all,


Who wants to bang his head against the wall with me ? smile smile smile


Here is the problem :
- I have a table (asset) with 35.000+ rows in it.
- each row has a calculated field
- on load in a tablegrid, it takes 1 or 2 seconds to load and display, which is ok on first Form show.


From time to time, the user makes some changes and the calculated fields should be recalculated but I would like to update only the modified row, and not recalculate all 35.000+ rows.


My question is : is it possible, when displaying a lot of rows in a tablegrid, to only update the corresponding row (the modified one) instead of updating all the tablegrid ?


Instead of

Form1.Tablegrid1.dbUpdate;

maybe something like

Form1.Tablegrid1.RecordUpdate[i];

Thank in advance for your answers


Cheers



Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Update 1 row in tablegrid after change

Hello.


It's not possible in the current version, but you can specify the property dbLimit for TableGrid to limit number of records in the TableGrid, thus reduce the time to show records.

procedure Form1_OnShow (Sender: string; Action: string);
begin
    Form1.TableGrid1.dbLimit := 1000;
end;

or you can edit values in cells directly instead using dbUpdate

    Form1.TableGrid1.dbItemID := id; // id - id edited record

    Form1.TableGrid1.Cells[0,Form1.TableGrid1.SelectedRow] := SQLExecute('SELECT field1 FROM tablename WHERE id='+IntToStr(id));
    Form1.TableGrid1.Cells[1,Form1.TableGrid1.SelectedRow] := SQLExecute('SELECT field2 FROM tablename WHERE id='+IntToStr(id));
    Form1.TableGrid1.Cells[2,Form1.TableGrid1.SelectedRow] := SQLExecute('SELECT field3 FROM tablename WHERE id='+IntToStr(id));
Dmitry.

Re: Update 1 row in tablegrid after change

Sorry I missed you reply. Thank you for the details Dmitry



Math

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor