Topic: How to copy tg footer to another tg cell / column

the following didn't work:

procedure Form1_OnShow (Sender: string; Action: string);
begin
Form1.tgSchools.Columns[3].Value := Form1.tgItems.Columns[3].Footer.FormulaValue;
end;
Adam
God... please help me become the person my dog thinks I am.

Re: How to copy tg footer to another tg cell / column

Hi Adam,
I'm guessing you'll be including it as part of some 'if' statement and processing through all the rows in the grid but the basic syntax that I'd use for the actual 'copy' of the footer value is:
  form1.tablegrid1.cells[1,1] := floattostr(form1.tablegrid1.columns[1].footer.formulavalue);
But there may be other ways too.
Derek.

3 (edited by AD1408 2019-02-10 04:31:51)

Re: How to copy tg footer to another tg cell / column

Hi Derek,

Thank you very much for your attention...........


Still couldn't sort out copying footer to another tg column..

Please see attached sample project:


https://i.postimg.cc/k5gvzLLn/copy-footer.png

Post's attachments

Attachment icon TEST_ComboData2ndTable.zip 123.6 kb, 290 downloads since 2019-02-10 

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

Re: How to copy tg footer to another tg cell / column

Hi Adam,
For me, the easiest way would be to use a calculated field and avoid doing it in the script.
(select round(avg(rating),2) from item where item.id_school = school.id) 
See attached.
Derek.

Post's attachments

Attachment icon TEST_ComboData2ndTable.zip 457.52 kb, 304 downloads since 2019-02-10 

Re: How to copy tg footer to another tg cell / column

Hi Derek,

Thank you very much for your kind help..............
Truly appreciated.................

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

6 (edited by AD1408 2019-02-12 01:01:12)

Re: How to copy tg footer to another tg cell / column

derek wrote:

Hi Adam,
For me, the easiest way would be to use a calculated field and avoid doing it in the script.
(select round(avg(rating),2) from item where item.id_school = school.id) 
See attached.
Derek.

Sample project on the post above.

https://i.postimg.cc/5yGc7z6z/delete521.png

I realized that, when deleting a school on schools grid, items belonging to school on items grid get deleted too. I have no idea how to do this but I like add some safety to prevent such deletes:


When school grid delete button clicked, check to see if there is any records listed in item grid belonging to the record user trying to delete. If there is then delete canceled with custom message "Cannot delete........ etc"


edit:
-----------------
tried the following but didn't work fully:

procedure Form1_btnSchoolDELETE_OnClick (Sender: string; var Cancel: boolean);
begin
if Form1.tgItem.RowCount > - 1 then
   begin
   Cancel := true;
   MessageBox ('Reord you are trying to delete contains sub records. You must delete sub record/s first.','Error',MB_OK+MB_ICONERROR);
   end;
end;

couldn't clear cancel:=true so that user can delete main record after clearing sub records.

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