How can I sort checkbox columns?
While migrating grids from TMSFNCGrid to TMSFNCDataGrid I can not find a solution for sorting checked rows …
How can I sort checkbox columns?
While migrating grids from TMSFNCGrid to TMSFNCDataGrid I can not find a solution for sorting checked rows …
Hi,
You can use this approach:
function TForm10.TMSFNCDataGrid1CustomCompare(Sender: TObject; AColumn, ARow1,
ARow2: Integer; AData1, AData2: TTMSFNCDataGridCellValue;
ALevel: Integer): Integer;
function CompareBool(left, right: boolean): integer; overload;
begin
Result := Ord(left and not right) - Ord(right and not left);
end;
begin
if AColumn = 2 then
Result := CompareBool(TMSFNCDataGrid1.Booleans[AColumn, ARow1], TMSFNCDataGrid1.Booleans[AColumn, ARow2])
else
Result := EqualsValue;
end;
procedure TForm10.TMSFNCDataGrid1GetSortOptions(Sender: TObject; AColumn,
ALevel: Integer; var AOptions: TTMSFNCDataGridDataSortOptions);
begin
if AColumn = 2 then
AOptions.Format := gsfCustom;
end;
Hi,
I had a lot of crashes after implementing your solution. Unfortunately I could not locate the exact line that threw exceptions…
There is another interesting solution:
Hi,
Please provide some more context around the crashes, so far it’s unclear what those crashes are. The solution can indeed help, to hide the text it might be better to use:
procedure TForm1.TMSFNCDataGrid1BeforeDrawCell(Sender: TObject;
AGraphics: TTMSFNCGraphics; ACell: TTMSFNCDataGridCell;
var ACanDraw: Boolean);
begin
ACell.DrawElements := ACell.DrawElements - [gcdText];
end;
Works fine…