#1 2014-02-20 07:42:37

noobies
Member
Registered: 2011-09-13
Posts: 139

autosize column width

i use drawgrid autosize column width, but it work terrible, maybe I do not see how you can control the functions they.
small rewrite source mormot.pas from (https://www.dropbox.com/s/iwf6npz0lufle … column.JPG)

    for R := 1 to RowCount do // sum all lengths by field
      for F := 0 to FieldCount-1 do begin
        case fFieldType[F].ContentType of
        sftInteger, sftBlob, sftBlobCustom, sftUTF8Custom, sftRecord,
        sftID, sftSet, sftCurrency:
          inc(aResult[F],8);
        else inc(aResult[F],Utf8FirstLineToUnicodeLength(U^));
        end;
        inc(U); // points to next value
      end;

to

var nullfield: integer;

    for R := 1 to RowCount do // sum all lengths by field
      for F := 0 to FieldCount-1 do begin
        case fFieldType[F].ContentType of
          sftDateTime: inc(aResult[F],8)
          else begin
            nullfield := Utf8FirstLineToUnicodeLength(U^);
            if nullfield = 0 then nullfield := 8;
            inc(aResult[F],nullfield + 1);
          end;  
        end;
        inc(U); // points to next value
      end;

and see more better i think (https://www.dropbox.com/s/xmnveo759oskn … column.JPG)

Offline

#2 2014-02-20 10:05:25

noobies
Member
Registered: 2011-09-13
Posts: 139

Re: autosize column width

problem see on last 3 column, he have data not in each row and standart algoritm compress column. fix normalize size column

Offline

#3 2014-02-20 13:54:31

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,240
Website

Re: autosize column width

All this is interesting feedback.

So what is your final proposal?

Offline

#4 2014-02-21 04:28:08

noobies
Member
Registered: 2011-09-13
Posts: 139

Re: autosize column width

yes at the moment, in the six months were no complaints.
but I think it is not the best option, because know only superficially framework

Offline

Board footer

Powered by FluxBB