Subject RE: [IBO] Column ordering
Author Helen Borrie
At 10:11 AM 24/03/2003 +0200, you wrote:
>As nobody answered to me, I have to do it myself.
>
>It appears, that suddenly one property - position of the grid columns - is
>stored into TIB_Grid properties, namely GridLinks. And this overwrites the
>TIB_Query's FieldsIndex.

Yes, that is the purpose of GridLinks.

>At the same time the grid column width is still determined in the
>TIB_Query?!? The logic of this escapes me.

If you don't specify an override width for a field named in GridLinks, that
field's FieldsDisplayWidth stands. You can use the Gridlinks for
overriding the FieldsIndex ordering alone, or for both ordering and display
width.


>But there is still on problem.
>If I set the columns ordering, and user reorders them, I can get the the
>order at the closing my form. That's fine.
>BUT, if I dont set the orders specifically (I use the defualt values),
>then I can't get the new orders at the end. I can reorder them as much I
>like, but when closing the form , the GridLinks property is empty.

By the time the form is closed, the linking between the dataset fields and
the GridLinks is gone. It is ONLY a display-time override and it only
affects *that* grid. GridLinks doesn't change the dataset properties.


>This means, that I must specifically set the grid columns for each of my
>grid (and some of them can have different datasets at the time).
>Why do I HAVE TO populate this property manualy?

I think you answered your own question in a way...any lengths you apply to
GridLinks are *linked* to dataset columns. When you remove the column that
it refers to, the GridLink is cleared.

I think if you want to use GridLinks for these attributes, you should read
the Gridlinks settings before the dataset closes, and save those for
restoring to the grid, without touching the FieldsIndex.

> > -----Original Message-----
> >
> > IBO 4.2Hc

This is quite an old version. You might be encountering an old GridLinks
bug. If you are also using an old help file, you might not have the
documentation of the changes that were done, either.

> >
> > I thought to save the ordering of Grid columns into INI file
> > so that users could set their prefered order.
> > I tried to use FieldsIndex->SafeCommaText. For saving it's
> > 'OK, but in loading it behaves very strangely.
> > Query->FieldsIndex->SafeCommaText=NULL;
> > Query->FieldsIndex->SafeCommaText="NAME,UID,BDATE";
> > String Str=Query->FieldsIndex->SafeCommaText;
> > And suddenly in next line
> > Str="UID,BDATE,NAME";
> >
> > How come????

This doesn't look like a healthy way to clear and load a TStrings. You
need to call its Clear method and then, after that, you could *try*
assigning the SafeCommaText string.

But I'm not sure this error is the cause of the actual problem. The Str
you get is returning (presumably) the SQL Field order (i.e. the starting
FieldsIndex, which is built when the query is prepared). Possibly, the
assignment couldn't be made whilst the dataset is active..my guess is that
it needs to be done whilst the dataset is closed. It would be worth trying...

Just curious...what is this 'NULL' that you are assigning to this
string? I suppose that, if it doesn't cause an exception in C++, it must
be OK. In Delphi, Null can only be assigned to a variant.

cheers,
Helen