Start a new topic
Answered

Order of objects in a Report

I am writing a report containing a table with objects. I would like the order of the objects to be the same as the order seen in the System Weaver main window where the objects are located. 


I have used the command ForEach with the addition OrderBy(Name). But that of course only sorts by name. Are there other sorting orders? 


Thank you!


Best Answer

You can use <ForEach> and get the part number ordering if traversing in two steps.

First get the parts and order by the part ordering e.g.,


<ForEach select="/part::SID.OrderBy(PartNo)"> ...


This will give you a list of parts with the same ordering as in the tree. You need to operate on parts to be able to sort on the part number ordering. From here you can get the items by using either:


<DefObj> or <ForEach select="/defobj::">


Best regards

Martin


Thank you for your answers! 

I tried the two-step approach with <ForEach> but with no success. 

Thereafter I used the <ForEachPart> and <DefObj> and that worked as intended for me.


Thank you for your support!

/Johan

Answer

You can use <ForEach> and get the part number ordering if traversing in two steps.

First get the parts and order by the part ordering e.g.,


<ForEach select="/part::SID.OrderBy(PartNo)"> ...


This will give you a list of parts with the same ordering as in the tree. You need to operate on parts to be able to sort on the part number ordering. From here you can get the items by using either:


<DefObj> or <ForEach select="/defobj::">


Best regards

Martin

Hi Johan,


To get a part number ordering when you use context you need to use the <ContextGoYY> tags. When not using context the <ForEachPart><DefObj> tags use the part number ordering as default.


The <ForEach> tags do not use the part number ordering. The path language that is used with the <ForEach> tags operate on sets of items. This means that you loose the parts during the evaluations which means that you do not have access to the part ordering. 


So to get the same ordering as in the tree do not use <ForEach>.


Best regards

Martin

 Hi Johan.

You can use OrderBy(PartNo).

The printout will be according to the order you have in the structure, which is the partnumber order.

Regards, Peter

Login to post a comment