TableView / Categories Issue

Hello,

in my code I set several categories with the following code
------------------------
  while not Eof do
  begin
    with tmsfmxtblvwDisc.Categories.Add do
    begin
      Caption := Fields[1].AsString + ' (' + Fields[2].AsString + ')';
      Id := Fields[0].AsInteger;
    end;
    Next;
  end;
----------------------

Afterwards I set the items with the following code
-------------------------
  while not Eof do
  begin
    with tmsfmxtblvwDisc.Items.Add do begin
      Caption := Fields[2].AsString;
      CategoryID := Fields[0].AsInteger;
    end;
    Next;
  end;
---------------------------

The resulting tableview displays the caption only for the first categories. For all other categories I see a blank caption. Is this a bug?

Kind regards
Gernot

We are not experiencing difficulties here, with the following code, and a default tableview on the form, it works as expected.


var
  cat: TTMSFMXTableViewCategory;
  I: Integer;
begin
  TMSFMXTableView1.BeginUpdate;
  TMSFMXTableView1.Items.Clear;
  TMSFMXTableView1.LookupBar := True;
  TMSFMXTableView1.CategoryType := ctCustom;

  cat := TMSFMXTableView1.Categories.Add;
  cat.Caption := 'Section Cat 1';
  cat.LookupText := 'Cat 1';
  cat.Id := 0;

  cat := TMSFMXTableView1.Categories.Add;
  cat.Caption := 'Section Cat 2';
  cat.LookupText := 'Cat 2';
  cat.Id := 1;

  cat := TMSFMXTableView1.Categories.Add;
  cat.Caption := 'Section Cat 3';
  cat.LookupText := 'Cat 3';
  cat.Id := 2;


  for I := 0 to 4 do
  begin
    with TMSFMXTableView1.Items.Add do
    begin
      CategoryID := 0;
      Caption := 'Item on Category 1';
    end;
    with TMSFMXTableView1.Items.Add do
    begin
      CategoryID := 1;
      Caption := 'Item on Category 2';
    end;
    with TMSFMXTableView1.Items.Add do
    begin
      CategoryID := 2;
      Caption := 'Item on Category 3';
    end;
  end;
  TMSFMXTableView1.Items.Sort;
  TMSFMXTableView1.EndUpdate;

Kind Regards, 
Pieter

Update: it is always the last Category Caption that is missing, even so it is set (I did a ShowMessage just before assigning it)

Kind regards
gernot

Did you test the sample, the sample works as expected so there must be something missing in your code, 

can you wrap the loops with beginupdate / endupdate?

Pieter

Your code works. Mine is wrapped in beginUpdate/EndUpdate. I will continue to investigate this.

Kind regards
gernot

I cannot find anything wrong in my code. The weirdest thing is that I use this code identically in a version for iOS with your Native controls and sections instead of categories and there it works flawlessly.


Kind regards
Gernot

Can you perhaps send us a sample, or send us your code so we can investigate this here?


Kind Regards, 
Pieter

Sure - will do


Kind regards
Gernot