cancel
Showing results for 
Search instead for 
Did you mean: 

How to sort a column directly after data is filled into the grid?

Former Member
0 Kudos

Hello,

I have a unbound field X, which is filled on fly in the RowLoaded2 column. If I click on the column header, I am able to sort the column.

I want to sort the column directly, but all attempts have failed.

I have tried to call in <anchor>_OnUpdate

<anchor>.bcol.Sort( "X", "ASC") but it does not work as long as the property is not mapped to a Segment field of a bdoc. For this test i just created my property X on the Business Objects behind the tablegrid

I have used <tablegridcontrol>.sortCol = 2, but it results into a StackOverflowException even for any other column.

Is there no way to sort the colum in this special kind of situation?

Regards,

Andreas

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I am afraid that this is not possible as the way of sorting you are using is based on the query BDoc segment. The sorting via user interaction is based on a framework functionality, therefore also sorting based on unbound columns is possible.

Why not using an unused standard field for storing your field, and doing the sorting in the query BDoc directly? Then a <anchor.refresh> command would solve your problem.

Regards,

Wolfhard

Former Member
0 Kudos

The thing is, I actually wanted to avoid this way! Touching the SAP 'vanilla' elements could result into new issues, so I hoped to find a way to trigger something in the same way as a user interaction would do. It's hard to understand, why the framework does not allow me to trigger those things.

I keep on dreaming of a clean development without having any hacks ...

Former Member
0 Kudos

Hi,

I stopped dreaming after working with MSA since 8 years now...;-)))

But maybe it is working if you are setting the property SortCol of the class CoreCtrlGrid e.g. define the sorting of the grid instead of the collection. It looks that you also need to fire FireGridSort afterwards.

Regards,

Wolfhard

Former Member
0 Kudos

Hi,

as described ealier, i already tried this and it results into a fatal StackOverflow Exception. I tought in the beginning it was related to the method onUpdate or RowLoaded2, where i tried to call this, but somehow I am unable to see a recursive call-loop while debugging.

A off-topic question, is there any API documentation available for all SAP VB classes?

Regards,

Andreas

Former Member
0 Kudos

Hi,

sorry for my short-term memory...;-))

I don't know whether there is an API documentation available, probably the SAP colleagues from development would know that.

I am always using the object browser in MAS for searching for useful methods.

Regards,

Wolfhard

Former Member
0 Kudos

Hi Andreas,

You have mentioned that you tried using sortcol and it resulted in stack overflow. Can you tell me in which evenhandler did you put this code. Try putting it in mcore_onload so that it is called only once.

Also the Mobile Technology framework API documentation is provided with the installation itself. It is in the Bin.NET folder, file name MTFrameworks50.chm.

regards

Vivek

Former Member
0 Kudos

HI,

I have tried to called it in the corresponding <anchor>_OnUpdate and <CoreCtrlGrid>_RowLoaded2 event, both show the same reaction.

I think the onLoad event is not suitable as I actually have to sort the columns after the unbound columns are sorted - which is not the case for onLoad (as I think).

Thank you for the hint, the chm file is exactly for what I was looking for!

Cheers,

Andreas

Former Member
0 Kudos

Hi Andreas,

I asked you to try on mcore_onload so that you come to know whether sortcol is working properly or not. If this works, then you can also make out that the infinite loop is being caused by calling the sortcol in rowloaded event.

And then you can call this with an exit criteria so that it is not causing stack overflow.

If it still does not work, then raise a OSS message under component CRM-MT-FW-UI and describe the problem.

cheers

Vivek

Former Member
0 Kudos

Hi,

you have to consider that when loading a tile for the first time always rowloaded2 is fired (several times) and afterwards onload. Maybe rowloaded2 again afterwards. So it should work to sort in onload.

But when clicking the <back> button in the menue the order of the fired events might be different!

Do you want to sort by an unbound column which is readonly or is it also editable (see other thread)? In this case things might be much more complicate... Normally another sorting should be done in onsave event but unfortunately you don't save anything as it is unbound...

Regards,

Wolfhard