form query calculation very slow

I have a sales details form which also displays totals by region for sales quantity, sales amount etc.

This worked fine in Axaota 4.0. But , after migrating to Axapta 2009, it takes ages to work out the calculation and display. The grid itself fills up fast. It is only the sum data that is slow.

The code used is looping through query output such as

do

{

cij = this.queryrun().getno(1);

additions based on region

} while this.queryrun().next();

Can anyone help me with this problem?

Thanks

Hi

I found out the solution to the problem. I had to add the line

Grid.Autosizecolumns(false)

to form Init method.

This prevents the grid from resizing columns as each query output line is read. Now the calculations happen much faster.

Regards

Hi

I am having also similar problems with some long sum querys.

Where do i exactly add the line

Grid.Autosizecolumns(false) ?

Regards

In the init method, just under the form.

Sorry, but i must be very blind…

Can not find that.

Can you send me some print screen?

Regards

autosizecolumns() was introduced in some kernel rollup - SP1 KR2 or something.

But I find the whole approach to the summary (“while this.queryrun().next();”) fundamentally wrong. It runs on client, fetchs records one by one etc. I would copy the query, apply any additional criteria (to meet the “based on region” requirement) and use SUM() aggregation function to calculate the value. The result is a single call to database returning a single value and not influencing the datasource in any way.