TDBAdvGrid problem with more than 255 columns from DataSource

Hello,
i have the problem, when my DataSource has more than 255 columns.
I want to add/remove columns in the Grid programmatically. By setting a fieldname (what exists in the DataSource) it keeps the set fieldname, but shows row content from different field. (PageMode true or false will not change the issue)
By all my tests this seems to be a problem, when the DataSource has more than 255 fields.
The TDBGrid component makes everything correctly.

I updated to current TMS UI Pack version 13.0.4.0 but the issue is still there.

Can you please help me.

I cannot reproduce this.
This creates a 300 column TDBAdvGrid

procedure TForm1.Button1Click(Sender: TObject);
var
  i: integer;
  fd: TFieldDef;
begin
   for i := 0 to 300 do
   begin
     clientdataset1.FieldDefs.Add('col'+inttostr(i), ftString,50);
   end;
   clientdataset1.CreateDataSet;
end;

when this clientdataset is via a datasource connected to the TDBAdvGrid.

Yes i know.

Deactivate at the TDBAdvGrid AutoCreateColumns.
Have a DataSet with more than 255 Fields/Columns.
Add programmatcally at runtime one or a few columns of the first 255 columns from the DataSet by setting the FieldName. A Column is created, but look at the content of the rows from that column shown at the TDBAdvGrid (importand is of courcse, that you have different row content for each column to be able to see the difference/recognize the right columns content, like giving every columns row content the Fieldname or number of the column).

No problem can be seen:

Please isolate this and provide a test project with which we can reproduce the problem.

This worked too, with PageMode = true
Can you test/provide with PageMode = false?

I stop trying to guess what you do.
If a problem persists, please provide a sample source project that demonstrates the issue and hereby eliminates all guesswork here.

The want was exactly like you tried to built up.
Just with PageMode = true it doesn't work

In this example, I used a default TDBAdvGrid and default PageMode = true.
So, my test was with PageMode = true!
Again, provide a sample source project + exact steps otherwise you and I just lose time.

Sorry, now i got confused by all my tests.
I mean i need it with PageMode = false

First i tried with AutoCreateColumns = true
and deleting unwanted columns by FieldName
then i tried to add just that columns i need with AutoCreateColumns = false
what also did not work

My want is to show just some columns, not all from the DataSource.
And by trying to get this it worked with DataSource below 256 fields, not above.

What was not clear?

"Again, provide a sample source project + exact steps otherwise you and I just lose time."

Finally i found the problem:
It's not a issue with the amount of columns, but if the dataset fieldlist is sorted and differ by that from the normal order.
Here a C++ sample:

int cols = 50;

DBAdvGrid1->PageMode = false;
DBAdvGrid1->Columns->Clear();

TDataSource *ds = new TDataSource(this);
TClientDataSet *ClientDataSet1 = new TClientDataSet(this);
ds->DataSet = ClientDataSet1;
ClientDataSet1->FieldList->Sorted = true;
DBAdvGrid1->DataSource = ds;

DBAdvGrid1->AutoCreateColumns = false;

for (int i = 0; i < cols; i++)
{
	ClientDataSet1->FieldDefs->Add("col" + String(cols-i), ftString, 50);
}
ClientDataSet1->CreateDataSet();

ClientDataSet1->Edit();
for (int i = 0; i < cols; i++)
{
	ClientDataSet1->FieldByName("col" + String(cols-i))->AsString = "data" + String(cols-i);
}
ClientDataSet1->Post();

ClientDataSet1->Active = false;

TDBGridColumnItem *col = DBAdvGrid1->Columns->Add();
col->FieldName = "col18";
col->Header = col->FieldName;
col = DBAdvGrid1->Columns->Add();
col->FieldName = "col32";
col->Header = col->FieldName;
col = DBAdvGrid1->Columns->Add();
col->FieldName = "col4";
col->Header = col->FieldName;
ClientDataSet1->Active = true;

Compare the Header (FieldName) with the content.

It is FieldList.Sorted = true that was causing the dataset to return an incorrect field index.
We've implemented a fix for this that will be included in the next update.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.