Is it possible to collapse categories (i.e., hide their items) with TTMSFMXTableView?
I can brute force it (sorta). I can do:
procedure TPartsTableViewFrame.tblPartsCategoryClick(Sender: TObject;
ACharacter: string; ACharacterID: Integer);
var
i: Integer;
begin
inherited;
tblParts.BeginUpdate;
try
for i := tblParts.Items.Count - 1 downto 0 do
if StartsText(ACharacter, tblParts.Items.Caption) then
tblParts.Items.Delete(i);
tblParts.Items.Sort;
finally
tblParts.EndUpdate;
end;
end;
However, there are a few problems with this:
Slow of course
OnCategoryClick is not available for the category items (only the Lookup items) so it does not work with Custom Categories.
Have to delete items (I tried setting Visible := False but it looks like the TableView requires control of Visible and shows them anyway
By deleting items, the item is no longer available in searching/filtering
The TableView hides the category completely when it is empty so I cannot click it again to show items
Any help appreciated.
Tom
By the way, if you type TTMSFMXTableView in the Search box and the radiogroup is set to forums, you get a SQL Injection server error.
<strong style="color: rgb0, 0, 0; font-family: 'Times New Roman'; font-size: medium; line-height: normal;">Server Error in Forum ApplicationWARNING: SQL Injection attack detected. Please contact the forum administrator. <strong style="color: rgb0, 0, 0; font-family: 'Times New Roman'; font-size: medium; line-height: normal;">Support Error Code:- err_SQLServer_SqlInjectionTest() <strong style="color: rgb0, 0, 0; font-family: 'Times New Roman'; font-size: medium; line-height: normal;">File Name:- functions_common.asp </strong></strong></strong>
The admin should fix that. :-)
It's the forum software that is being used (3rd party solution) that is sensitive to the word "table".
Pieter
(Pieter)
March 7, 2016, 8:49am
4
We have investigated this here, the HTML text takes on the click event handler, you can customize this and handle the event handler from the OnCategoryCustomize event:
procedure TForm1.DoCategoryClick(Sender: TObject);
var
i: Integer;
it: TTMSFMXTableViewItem;
cat: TTMSFMXTableViewCategoryShape;
c: string;
begin
cat := (Sender as TTMSFMXTableViewCategoryShape);
if Assigned(cat) then
begin
c := cat.Character;
TMSFMXTableView1.BeginUpdate;
try
for i := TMSFMXTableView1.Items.Count - 1 downto 0 do
begin
it := TMSFMXTableView1.Items;
if StartsText(c, it.Caption) then
it.Visible := not it.Visible;
end;
TMSFMXTableView1.Items.Sort;
finally
TMSFMXTableView1.EndUpdate;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
TMSFMXTableView1.CategoryType := ctAlphaBetic;
end;
procedure TForm1.TMSFMXTableView1CategoryCustomize(Sender: TObject;
ACategoryShape: TTMSFMXTableViewCategoryShape);
begin
ACategoryShape.ShapeCaption.HitTest := False;
ACategoryShape.OnClick := DoCategoryClick;
ACategoryShape.HitTest := True;
end;
Hi Pieter,
Thank you for your reply. On my system, the code you wrote crashes sometimes . The EndUpdate in DoCategoryClick causes CleanUpCategories to be called. Sometimes this code frees the TTMSFMXTableViewCategoryShape that is in the middle of its click. After the click, it tries to do the click animation and boom!
Tom
Pieter
(Pieter)
March 9, 2016, 11:57am
6
Hi,
We have applied a fix for this issue, the next version will address this.