Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Implementing an Autosort feature

edited September 2001 in General
Hi all,

I am trying to solve the problem that RB does not have an Autosort feature
in the same way as it does AutoSearch. It is going OK but I have hit a few
problems. The only way I can see to implement this using the existing RB
DADE interface is to use the existing AutoSearch framework and modify it a
bit. What I want to end up with is a panel that appears on the autosearch
dialog and has a combo box filled with field names from which a user can
choose one to sort the report data on.

I have already derived a nice set of custom autosearch panels that work
great, so I thought I would derive one to deal with searches too. I thought
I could add a new fake SearchOperator, soSortBy, and use this to pick up
what fields had been selected for sorting in the DADE. The first problem is
that you cannot change much of the code in the pp units without the da units
complaining about having been compiled with a different version of the unit
you changed. So I was forced to use soInNotList as a tag that would
identify the field as an AutoSort field.

I managed to get my Custom autosearch dialog to identify an autosort was
needed, build a panel with a combo box and fill it with all fields names
where the SearchOperator=soNotInList.

I followed an example from RB to get the SQL object and did the following to
remove existing OrderByFields

for x:=0 to lSQL.OrderByFieldCount-1 do
lSQL.OrderByFields[x].Free; //is this safe or does
it leak?

Then I tried to do the following

lSQL.AddOrderByField(AutoSearchFields[x],True);

But here the main problem lies. AutoSearchFields are of a different type to
OrderByFields, so how can I get the selected AutoSearchFields fields to be
added to the OrderByFields?

I feel like I am so near to creating a passable solution, but would far
rather see an official RB AutoSort feature. Is there one on the cards at
all?

Thanks for any input or help.

Surely someone else out there has had a go at this, maybe with more success
than me?

Cheers.

John.


--
I don't like spammers so send your spam to
abuse@hotmail.com

Comments

  • edited September 2001
    Hi John,

    I don't want to depress you, but has it crossed your mind that if the report
    contains groups and subgroups based on the order in which you expect the
    data to be supplied from the query, allowing the end-user to change the
    sort-order will screw up the report completely?
    eg if the report has Group[0] Customer.Code, Group[1] InvItems.Invoice, and
    the end-user changes the sort order to InvItems.ItemCode, you will get group
    headers and footers popping up all over the place.

    Or maybe your autosort is designed to take groups into account?

    Roj


This discussion has been closed.