sort PageDataCollection var based on Tree View - sorting

I've a function in C# that returns a PageDataCollection variable.
How can I sort this PageDataCollection based on the Episerver Tree View? (the pages are shown in the tree view in a certain order)
I use Episerver 6 R2

You can use the PageChildOrderRule property to check the sort setting (e.g. by index, publish date, etc) and the PagePeerOrder to get the sort index (numeric value used if sort order is set to index).
In other words, each page sets how its children are sorted. This in turn is how the page tree is rendered.
These properties are retrieved through the Property indexer on your PageData object, for example:
int sortIndex = (int)CurrentPage["PagePeerOrder"];

Related

GWT (smartgwt) grid sort selected records top

I have a grid where the user can select records via checkbox in front of every record. Now I have a requirement to sort the records based on their selection, so that all selected records should be placed top, followed by the not selected ones.
Is there any standard function to achieve this? As an alternative I thought of saving the selection state as an attribute on every record and sort based on the attribute.
The code for the column is:
gridRealmDt.setSelectionType(SelectionStyle.SIMPLE);
gridRealmDt.setSelectionAppearance(SelectionAppearance.CHECKBOX);
I try to describe the code I use as the affected code is deeply nested in our own framework classes.
gridRealmDt is a subclass of smartgwt ListGrid. In my Dialog a create an instance of the grid which creates an instance of a database bound datasource. When the dialog is loaded the records are fetched from the database and after that a registered an dataArrivedHandler where I select the records which match records from another table.
I tried to place the selection attribute in an extra field and use that for sortig before my other sort criteria, but this does not work. Here is the code for the field I am using.
ListGridField txtSelected = new ListGridField(SELECTED, "");
txtSelected.setHidden(true);
txtSelected.setSortByDisplayField(true);
txtSelected.setCanSortClientOnly(true);
When I do not set the canSortClientOnly property the order by is sent to my database resulting in an error, as the table does not contain that field, so I set the property. Now I get following error
Removing field from the sort Specifier array because it specifies canSort Client Only: true and all data is not yet client-side.
I also tried to use a sortNormilizer on the Name field which is my main sort criteria, but the normalizer is called before the selection value is set to the record.
record.setAttribute(CARealmDS.SELECTED,selected ? "a" : "b");
I also cannnot find a way to call the normalizer when selection changes.
Currently we are using Smart GWT Version 6.0p.
I don't think there is any standard function. Just use grid store update. Place checked items first.

MS Access table list order is defaulted in subform

I have a subform with a table, where some fields are restricted to tables. The tables are sorted in the correct order, but when it is used in the subform, it is set to default sorting. I can't find the location of the correct place to set the sorting criteria. I tried using query instead of a table, but i could only sort either by ascending or descending (or nothing). All three options resultet in undesired order. Example of the phase being sorted as default despite the table settings:
Suggestions?
As Gustav suggests, add another field to your t_Phase table, which will be the order you want this list to appear in the drop-down (make sure it is a number field):
Supply the numeric order:
In your other table, you can use the ID field from your t_Phase table by selecting it through the lookup wizard:
Move across the ID and the new "Order" field you just created:
Use the "Order" field as the field you want to use for sorting and make sure "Ascending" is selected:
Continue through the wizard:
Select the field that has the data you want to go in to the record of your table (I assume it's the ID field rather than the Order field, so make sure ID is selected):
Finish the lookup wizard and go in to Datasheet View on your table and check that the dropdown is now in numeric order. You've probably noticed a problem though as it is showing both the ID and the Order columns:
To hide the unnecessary Order column, go back in to Design View and click on your phase field to select it.
At the bottom should be a "Lookup" tab. Click on this and notice the Column Widths property... it's showing 2 different widths values; the first one is the ID field and the second one is the Order field. Set the Order field to 0cm to hide it. I'd then recommend setting the remaining Id field width to something that will be wide enough to show all your ID field's options. Then I'd set the List Width property to the same width.
8cm, for example:
This should result in something like the following, which is hopefully what you're after.
If you're not adding a lookup field to the design structure of a table, but are instead using a combo-box on a form or subform, the principle is pretty much the same; you'll just have to amend the combo-box properties from the form's Property Sheet "Format" tab instead:
Combo- and listboxes always contain text, thus your column is not sorted numeric.
To have a numeric sort, add a column with the number only and - in the source - sort only on that. If you don't the number separately, create it from this expression:
Val(Mid([PhaseField], 7))

ExtJs4 Mapping a treeStore level to a Store

What is a good way to map a level of a treestore to a flat store. In my case,
I want to group criteria for a search. All search criteria are inserted into the top level of the treeStore, unless they are grouped, in which case they become children of a top level logical(AND or OR) node. So, within a grid, I want to display the top level nodes (via some toString method I will define in the model). This is the easy part, I just go through the top level of my tree and generate the output for the Store/grid. However, when I want to remove something from the grid/store, it also needs to be removed from the treestore which represents the actual logical structure.
So, How can I keep track of which textual store item corresponds to which top level node in my treeStore?
Load your data onto the store or treegrid (but not both), then collect the records from one object and just add them to the other (using store.add() or treestore.getRootNode().appendChild()). At this point if you have a reference to the record, you can just say store.remove([record]); and then treestore.getRootNode().removeChild(record); to remove it from both.

jqgrid - treegrid for flat structure data

I have my data stored in database in flat structure with out any heirarchical fashion and currently displaying in tabular format using jqgrid. I would like to display it in drill down fashion like the count at the top levels, child levels like this in nested fashion. Is it possible to do using jqgrid...
I think that the best way to make some queries used GROUP BY on the server side to construct the information about the hierarchy of the data. In the way you will be construct the tree structures which you need. The main data will get isLeaf:true, level:4, expanded:false, loaded:true properties and parent property with the id of the parent node "2200". If you would use as ids the values with prefixes like 'e' for 'Event', 'm' for 'Model' and so on you will be easy construct unique ids for every row so you will be able to construct all data for the Tree Grid on the server and then place the data in the server response.
Alternatively you can fill only the top level of the tree grid. You can construct simply query which will produce the resulting set. If the user will opens some tree node the new request will be sent to the server. The request will contains the some additional parameters: nodeid, parentid and n_level. If you good choose the id values of on the root items you will have full information to construct query which will get you the next level on the tree. You should use parentid as to construct the WHERE part of the query. In the way you can also construct the tree and load all noded on-demand.

How can I show a flat representation of a GtkTreeStore in a GtkTreeView?

I have a TreeStore with objects that I view and manipulate through a GtkTreeView/GtkTreeModel setup.
I also have a TreeView showing a TreeModelSort of the TreeStore, which I use for sorting on columns like name and date.
The problem is, that the sort mechanism only sorts the root nodes, even if a underlying child node has e.g. a date that is later/sooner than the roo tnodes' dates.
So, the question is if there is any way to show the objects as a List, not a tree, but keeping the references to the paths in the other TreeView?
I would suggest a TreeModelFilter that filters out any rows that are child rows (ie, depth > 1). You can filter your sorted model, and display just the root nodes.

Resources