TFS 2010 sorting ALLOWED VALUES desc - tfs-workitem

I'm using TFS 2010.
I have a string field with a list of allowed values. When I view the work item the list is sorted alphabetically (the original list is not sorted alphabetically).
Is there any way to display the vaule order as the same given in the work item template.
Is there any way to change the sort order to desc?
I know I can write a custom control for this but I was wondering if there was any easier way.
thanks,

There is no way to sort a list of values (allowed, suggested, or even taken from a global list) in any order, but ascending alphabetically.
You do have two option though:
Add an index before each item on the list. This index would be something like "1. Banana", "2. Apple", etc. It would be permanent and would appear in the display of the list, but it is the simplest solution, if it's good enough for you.
You may create a custom control, that would appear as a drop down list, and would sort by a custom parameter that you can add to the work item type definition.
Hope this helps.

Related

Flex 3 MX List: need to programmatically reorder the list's item renderers

Ok, I have to use Flex 3 because I am using this in an Adobe Connect pod. I have a List component, which is capable of being reordered through drag and drop. If someone leaves the browser and comes back into the meeting room, I am trying to redisplay how they had items ordered from their drag and drop. So I need a way to reorder the list. I was looking into sort for Arrays on the dataProvider. But I have not been able to figure out the proper event to sort the list once, all of the items have the appropriate data in.
In any case, does anyone know how to tell the data of an itemRenderer to have ordered values, and then tell the list to reorder the items in the list according to the new values?
One of the possible ways I used:
Keep your data in Object(map) with key:value, Object{rowIndex:rowData}
e.g. {1 : row1Data,
2 : row2Data, ... }
Prepare the list values based on the keys and then assign it to the grid. This way, Itemrenderer will no longer need to know the "order" of the data. Their task is just to display the data.
Once user is done with drag-drop - update the map, persist it.
Hope this helps.
If you use an ArrayCollection, you can apply a sort, and then call arrayCollection.refersh() to refresh the collections with the sort, which will then update the list display

Add to list within document MongoDB

I have a database where I store player names that belong to people who have certain items.
The items have and IDs, and subIDs.
The way I am currently storing everything is:
Each ID has its own collection
Within the collection there is a document for each subID.
The document for each subID is layed out like so:
{
"itemID":itemID,
"playerNames":[playerName1, playerName2, playerName3]
}
I need to be able to add to the list of playerNames quickly and efficiently.
Thank you!
If I understood your question correctly, you need to add items to the "playerNames" array. You can use one of the following operators:
If the player names array will have unique elements in it, use $addToSet
Otherwise, use $push

Django: Find element in list by value

I have a sorted list of objects that I want my users to select a range from. For this I added two select elements (called from and to)to my web page. from is filled directly from the list, like this:
<select id="from">
{% for el in el_list %}<option>{{el.number}}</option>{% endfor %}
</select>
Once a value has been selected in from I'd like to populate to with the values from the selected value until the last one.
The list is sorted by the number attribute on python's side so I guess all I need to do is find the selected element in the list, slice the list accordingly and use the rest to populate my second select.
I've searched the documentation and several snippets but so far I've only found filters giving me the last or the first element of a list. I also know I can check if the selected value is in my list using in, but how can I then get that object's index?
I know I could probably run along the whole list with a for ... if, but I am almost sure there's a more elegant method out there, that I simply haven't found yet.
If any of you could provide me with a few pointers on how to solve this more elegantly it'd be much appreciated.
I don't know why you're looking through template tags for this. They won't help: by the time the user sees the page to select something from the from select, the template has already been rendered. You need to use Javascript.

Flex4.6 Add element to top of List

I've got a spark list that gets dynamically filled.
So far the new items appear at the bottom of the list. What I'd like to do is to add them at the top.
The items in the list have a unique ID so some kind of sorting mechanism would probably do the trick as the new items have a greater ID than the old ones.
What I'd like to avoid is some complex method behind this as I'm working on a mobile platform and the list can get quite big so I need this to be as efficient as possible.
The list's data provider is an ArrayList that gets updated using binding.
How can that be done?
Thanks in advance!
u can Add the items at the starting index of the datagrid. Flex datagrid automatically renew all the indexes and add 1 to all existing element indexes. So
YourDataGridId.dataprovider.addItemAt(item,0) will do.

Automatically sorting on insert in QTreeWidget

I have a QTreeWidget that I insert items in, and the user can select a column to sort it. As the items are being inserted, they just get appended to the end instead of having the sort being done automatically. If I click the header to switch between ascending/descending it will sort the current items.
I figured I could call sortItems() and use the column that is returned from sortColumn(), but I am unable to see how I can see if the user is doing an ascending or descending sort.
I'm not worried about the efficiency of this, so I don't want to wait until the insertions are done and then do the sort. I'd like a real-time sorted list.
Thanks!
If your tree widget is called treeWidget, you should be able to call the header() method, which is from QTreeWidget's parent QTreeView, then sortIndicatorOrder() from the QHeaderView class:
treeWidget->header()->sortIndicatorOrder()
With this, you know the user's current sort order, and you can apply your sort on insert according to this.
I don't have a setup for testing but according to the documentation, this should cause sorting to occur as items are inserted.
...
treeWidget.sortByColumn(0, Qt::AscendingOrder); // column/order to sort by
treeWidget.setSortingEnabled(true); // should cause sort on add
Qt recommends against doing this as there will be a performance cost and say that you should set sorting enabled after all the adds are completed. Hope this helps.