Topic: tGrid data display

Hi All,


I'm trying to display inv and inv item details on a same tGrid. There are repeating values when an inv have multiple items. How can I hide (filter out) repeating cell values so that I could get correct footer sums and better view. By better view I mean, repeating cell values are not displayed.


https://s29.postimg.org/rvinuimuv/zzz_Test2.png


Please see the SaleTransHist form in the attched sample project

Post's attachments

Attachment icon tGrid Data.zip 15.4 kb, 390 downloads since 2017-01-04 

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

Re: tGrid data display

Hello.


Check it out

procedure SaleTransHist_tgSaleInvTransHist_OnChange (Sender: string);
var
    i,c: integer;
    sPrevRow: string;
begin
    sPrevRow := '';
    c := SaleTransHist.tgSaleInvTransHist.RowCount-1;
    for i := 0 to c do
    begin
        if SaleTransHist.tgSaleInvTransHist.Cells[0,i] = sPrevRow then
        begin
            sPrevRow := SaleTransHist.tgSaleInvTransHist.Cells[0,i];
            SaleTransHist.tgSaleInvTransHist.Cells[0,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[1,i] := '';
        end else sPrevRow := SaleTransHist.tgSaleInvTransHist.Cells[0,i];

    end;
end;
Dmitry.

3 (edited by AD1408 2017-01-05 10:02:31)

Re: tGrid data display

Hi Dmitry,


Thanks a lot............


Your script works fine for columns 0, 1, 3 and 4.
Problem seems to be handling currency field type with decimals and thousand separator.  Column 11 and thereafter filtered columns displays currency field types data. It produces error:  " is not a valid floating point value"

procedure SaleTransHist_tgSaleInvTransHist_OnChange (Sender: string);
var
    i,c: integer;
    sPrevRow: string;
begin
    sPrevRow := '';
    c := SaleTransHist.tgSaleInvTransHist.RowCount-1;
    for i := 0 to c do
    begin
        if SaleTransHist.tgSaleInvTransHist.Cells[0,i] = sPrevRow then
        begin
            sPrevRow := SaleTransHist.tgSaleInvTransHist.Cells[0,i];
            SaleTransHist.tgSaleInvTransHist.Cells[0,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[1,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[3,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[4,i] := '';

            // Columns those are not working
            {SaleTransHist.tgSaleInvTransHist.Cells[11,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[12,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[13,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[14,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[15,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[16,i] := '';  }
        end else sPrevRow := SaleTransHist.tgSaleInvTransHist.Cells[0,i];

    end;
end;


begin

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

Re: tGrid data display

Please download latest beta version here:
https://www.dropbox.com/s/1y0jek64gzfdy … a.zip?dl=0


Then check it out:

procedure SaleTransHist_tgSaleInvTransHist_OnChange (Sender: string);
var
    i,c: integer;
    sPrevRow: string;
begin
    sPrevRow := '';
    c := SaleTransHist.tgSaleInvTransHist.RowCount-1;
    for i := 0 to c do
    begin
        if SaleTransHist.tgSaleInvTransHist.Cells[0,i] = sPrevRow then
        begin
            sPrevRow := SaleTransHist.tgSaleInvTransHist.Cells[0,i];
            SaleTransHist.tgSaleInvTransHist.Cell[0,i].Empty := true;
            SaleTransHist.tgSaleInvTransHist.Cell[1,i].Empty := true;

            SaleTransHist.tgSaleInvTransHist.Cell[3,i].Empty := true;
            SaleTransHist.tgSaleInvTransHist.Cell[4,i].Empty := true;

            SaleTransHist.tgSaleInvTransHist.Cell[12,i].Empty := true;

            SaleTransHist.tgSaleInvTransHist.Cell[13,i].Empty := true;
            SaleTransHist.tgSaleInvTransHist.Cell[14,i].Empty := true;
            SaleTransHist.tgSaleInvTransHist.Cell[15,i].Empty := true;
            SaleTransHist.tgSaleInvTransHist.Cell[16,i].Empty := true;
        end else sPrevRow := SaleTransHist.tgSaleInvTransHist.Cells[0,i];

    end;
end;
Dmitry.

Re: tGrid data display

Thank you sooooooooo much Dmitry..........


Filtering out repeating cell values works perfectly with the beta you kindly offered.



However,  filtered out cell values still included in footer sum calc, hence showing incorrect footer totals.
Is there solution for this too?

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

Re: tGrid data display

Try to add 0 values for the cells, like this

SaleTransHist.tgSaleInvTransHist.Cells[12,i] := '0';
Dmitry.

7 (edited by AD1408 2017-01-06 00:05:50)

Re: tGrid data display

DriveSoft wrote:

Try to add 0 values for the cells, like this

SaleTransHist.tgSaleInvTransHist.Cells[12,i] := '0';

Tried... tGrid cells display 0.00 but somehow footer sum calc still includes those repeating cell values (even though they are displayed as 0.00 on tGrid cells) and produces wrong totals.


https://s24.postimg.org/ss49wqvph/zzz_Test3.png

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

Re: tGrid data display

After for to do try to add

SaleTransHist.tgSaleInvTransHist.CalculateFooter;
Dmitry.

Re: tGrid data display

Thanks a million Dmitry....


It didn't work adding after for to do. It brought back repeating cells values.


However, adding after each '0'; script lines like below worked fine:

SaleTransHist.tgSaleInvTransHist.Cells[11,i] := '0';
SaleTransHist.tgSaleInvTransHist.CalculateFooter;

Once again, thank you so much for your kind help..............

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