You are not logged in.
Pages: 1
function TSQLTable.CalculateFieldLengthMean(var aResult: TIntegerDynArray;
FromDisplay: boolean=false): integer;
...
for R := 1 to fRowCount do // sum all lengths by field
for F := 0 to FieldCount-1 do begin
case fFieldType[F].ContentType of
...
sftUnknown: aResult[F]:=0; // I ADD THIS TO WORK HIDE COLUMN
...
for F := 0 to FieldCount-1 do begin
if aResult[F] = 0 then Continue; // IF 0 HIDE COLUMN, SOME TIMES NEED HIDE COLUMN
n := cardinal(aResult[F]) div Tot; // Mean = total/count
if n=0 then n := 1; // none should be 0
aResult[F] := n;
inc(result,n); // fast calculate mean sum
end;
i hide column to save space in grid, approvedate - green color in table, declinedate - red color in table, not need show 2 column
tbl_patients := ClientRest.ExecuteList([], s);
tbl_patients.SetFieldType('approvedate',sftUnknown);
tbl_patients.SetFieldType('declinedate',sftUnknown);
or may be add new type sftNotVisible?
Last edited by noobies (2015-05-29 12:26:50)
Offline
I tried this function, but it's not what me need, especially as a function of the error if I specify the column in which the row 5 no data (for example, an empty string) function returns an error. (if all the rows have the data all works), though I do not understand why it can be necessary, because you can simply specify the column in the sql command.
I do not need to display an empty column without the data I need to hide a column.
i have wide monitor, but many users not have. User dont need last 2 column - color show approve or decline this record.
of course table show in auto resize
with TSQLTableToGrid.Create(dgList, tbl_Patients, ClientRest) do begin
ShowHint := False;
OnValueText := OnValueTextTablePatients;
OnDrawCellBackground := OnDrawCellBackgroundPatients;
Resize(nil);
...
end;
before
after
Last edited by noobies (2015-06-01 06:20:14)
Offline
quick fix
procedure TSQLTable.DeleteColumnValues(Field: integer);
var i: integer;
U: PPUTF8Char;
begin
if cardinal(Field)>=cardinal(FieldCount) then
exit; // out of range
U := @fResults[Field+FieldCount]; // U^ = column UTF-8 content for this field
for i := 1 to fRowCount do begin
if U^ <> nil then U^[0] := #0; // just void UTF-8 content text //ADD if U^ <> nil then
inc(U,FieldCount);
end;
end;
yes it works - column hide but have no data and no color((( Need only hide column without erase data
i think add sftNotVisible best solution
Last edited by noobies (2015-06-01 06:37:44)
Offline
ticket to bug, http://synopse.info/fossil/tktview/5a8e … 7c081f1177
Offline
Should be fixed by http://synopse.info/fossil/info/fff78b68b4
Offline
TSQLFieldType = (
sftUnknown, sftAnsiText, sftUTF8Text, sftEnumerate, sftSet,
sftInteger, sftID, sftRecord, sftBoolean,
sftFloat, sftDateTime, sftTimeLog, sftCurrency, sftObject,
{$ifndef NOVARIANTS}
sftVariant,
{$endif}
sftBlob, sftBlobDynArray, sftBlobCustom, sftUTF8Custom, sftMany,
sftModTime, sftCreateTime, sftTID, sftRecordVersion, sftHidden); //<=== add sftHidden, and other constants too
function TSQLTable.CalculateFieldLengthMean(var aResult: TIntegerDynArray;
FromDisplay: boolean=false): integer;
...
case fFieldType[F].ContentType of
...
sftHidden: aResult[F]:=0;
...
for F := 0 to FieldCount-1 do begin
if aResult[F] = 0 then Continue;
...
AB, can you add sftHidden to framework?
Offline
ab, sorry may be i slowpoke, but i dont understand how can i realize hidden columns by using TSQLTable.SetFieldLengthMean().
if write something like this:
SetLength(len, tbl_patients.FieldCount - 1);
for i := 0 to tbl_patients.FieldCount - 1 do len[i] := tbl_patients.FieldLengthMean(i);
len[colAproove] := 0;
len[colDecline] := 0;
tbl_patients.SetFieldLengthMean(len);
with TSQLTableToGrid.Create(dgList, tbl_Patients, ClientRest) do begin
ShowHint := False;
OnValueText := OnValueTextTablePatients;
OnDrawCellBackground := OnDrawCellBackgroundPatients;
Resize(nil);
...
end;
it does not work, since resize run after this code, and all columns recalculated
P.S. i try use TSQLTableToGrid procedure, but procedure has different format and apply for all column(((
procedure TSQLTable.SetFieldLengthMean(const Lengths: array of cardinal);
...
procedure TSQLTableToGrid.SetFieldLengthMean(const Lengths: RawUTF8; aMarkAllowed: boolean);
...
Last edited by noobies (2015-06-02 06:25:22)
Offline
ab, i rewrite some code and delete sftHidden, and add only 2 line to work hide, please add this line to framework.
how use to hide column
tblList.SetFieldType('approvedate', sftDateTime, nil, 0); //set ContentSize to 0
tblList.SetFieldType('declinedate', sftDateTime, nil, 0); //set ContentSize to 0
changes
function TSQLTable.CalculateFieldLengthMean(var aResult: TIntegerDynArray;
FromDisplay: boolean=false): integer;
...
case fFieldType[F].ContentType of
...
if fFieldType[F].ContentSize = 0 then aResult[F]:=0; // ADD THIS TO WORK
inc(U); // points to next value
end;
...
for F := 0 to FieldCount-1 do begin
if aResult[F] = 0 then Continue; // ADD THIS TO WORK
...
Last edited by noobies (2015-06-04 08:28:05)
Offline
Pages: 1