cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting on Grid

Former Member
0 Kudos

Hi

I am using SAPbouiCOM.Grid object. Sorting is Possible on Grid Object or not?

Please reply ASAP...

thnx & warm regards

deepak gaur

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member209699
Contributor
0 Kudos

Yes definitely u can do sorting on grid.

For this u have to load the grid again when u click on particular column.

Capture that event.

And sort accordingly in you query for that column eg.... Order by asc or Order by desc

regards:

sandy

Former Member
0 Kudos

Hi,

I want to add here that the SQL-"ORDER BY" Statement is "modified" by the Grid-functionality when using Collapse-level.

When a collapse-level of 3 (U_Col01 - U_Col03) is needed then my experience for the following example-query...

SELECT
   U_Col01,
   U_Col02,
   U_Col03,
   U_Col04
FROM
  [@TST_TABLE]
ORDER BY
   U_Col01,
   U_Col02,
   U_Col03,
   U_Col04

...is that the result in grid on the lowest level is NOT ordered by U_Col04.

What I needed to do was:

SELECT
   U_Col01,
   U_Col02,
   U_Col03,
   U_Col04
FROM
  [@TST_TABLE]
ORDER BY
   U_Col04

Which means: Don't use the collapse columns for the ORDER BYstatement.

I think the grid functionallity already do the GROUPing and ORDERing on the collapse columns and also using them in the query seems to confuse the grid-logic.

Can somebody confirm that?

Cheers,

Roland

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Roland,

I can confirm that the group funcaitonality in grid is using Collapse-Level, it is uncessary to add "GROUP BY" in the SQL.

Take your code as example:

When a collapse-level of 3 (U_Col01 - U_Col03) is needed then my experience for the following example-query...

SELECT

U_Col01,

U_Col02,

U_Col03,

U_Col04

FROM

[@TST_TABLE]

ORDER BY

U_Col01,

U_Col02,

U_Col03,

U_Col04

Set Collapse-Level as 3, meaning that the grid is grouped by first 3 colluons.

Of course, you don't need to order by the collapse collumn. Hope it is clear.

Cheers,

Yatsea

Former Member
0 Kudos

Set Collapse-Level as 3, meaning that the grid is grouped by first 3 colluons.

Of course, you don't need to order by the collapse collumn. Hope it is clear.

Hello Yatsea Li,

yes, the automatic GROUP and ORDER BY for the collapse-columns seems clear for me.

But I was wrong above, when I said that the ORDERing would work with the first column behind the collapse-columns (U_Col04 in example).

My problem here:

When I completely expand the last collapsed grid row it contains UNsorted rows (not correctly ordered by U_Col04)

When expanding the grid rows before the last one, they all contain correctly ordered by U_Col04 lines.

Then I've made a test:

1) The grid is loaded and expanded completeley (last expanded group is unsorted as stated above)

2) On a button-pressed event I changed the value of one row in the corresponding data-table (U_Col01) to a alphabetically high value ("ZZZZ")

3) The grid changes immediately and moves the row to a new grid group at the end of the grid.

4) Afterwards the rows in the grid group before last (which formerly was the last unsorted) IS CORRECTLY sorted

It seems to me as if there were a problem with sorting inside the last collaps-group of a grid...

Former Member
0 Kudos

Hi Roland, I confirm.

I have the same problem.

In a collapsed grid, i can't order by ungrouped column.

The not grouped columns don't follow the "order by" clauses.

Bye.

Former Member
0 Kudos

Hello Roberto,

I've made a new thread especially for this issue (I've marked it as "answered" in the meantime - unfortunatly because it's confirmed by SAP that sorting is not supported )-:

Maybe the chance of implementing this feature raises if you support this thread with a "yes-I-also-want-this"-answer:

Cheers,

Roland

Former Member
0 Kudos

Dear

Based on my knowledge, it is current

system limitation that it can not sort data in either Grid or Matrix by double clicking a specific row. In order to sort the data displaying, you need to use Grid rather that Matrix.

Please kindly review one of the

samples in the SDK help:

C:\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\19.Grid

It is a quite good example of how to use the grid and collapselevel. You will notice that they call the executequery statement to set the order of the fields and how they are displayed.

Best Regards,

Xiaodan AN

SAP Business One Forum Team

Nussi
Active Contributor
0 Kudos

Xiaodon,

FYI

you can use DataTable Object

in Grid and Matrix

thats why i wrote whith "Refilling" the matrix again you can give the user at least a feeling of sort:

DataTable .ExecuteQuery("SELECT CardCode, CardName, ... FROM OCRD ORDER BY CardName")

regards

David

Nussi
Active Contributor
0 Kudos

Hi Deepak,

cause you are using the Datatable object

and your assinging a query it is possible to use ORDER BY in the Select.

if you want a functionality like in a system matrix (find window) you will have no luck (Doubleclick on header)

but you can do it so that you catch the double click event and than set the query again with the correct ORDER BY

regards

David