Telerik MVC Grid: Setting the Default Sorting direction - model-view-controller

Is there a way to specify the default sorting direction for columns in a Telerik MVC Grid?
example: click on column 'Date' and it sorts descending, click on column 'Name' and it sorts ascending

I do not think there is a way in today's Grid to change the "cycle" order for sorting operations. By default, the Grid will cycle through these sort orders when the header is clicked:
Unsorted > Ascending > Descending
If you use the API options described by Dick, you can set the initial sort behavior, but once the column is clicked, it will "resume" the cycle. So, if you set Date to Ascending initially, the next click will sort by Descending.
This is relatively common behavior for web grids, so it meets user experience expectations.
If you want to take explicit control over sorting behavior, there is a rich client-side API that allows you to specify sort and filters directly:
var grid = $('#yourGridId').data('tGrid');
//Descendingly sort the records by the Name property
grid.filter('Name-desc');
As you can see, you can specify the property name and sort direction. You can also sort on multiple fields. See the online docs for more examples.

I suppose you can play with the OrderBy method of the Telerik MVC grid and define the sort order explicitly - at least this is what I see from the demo description here.
Dick

Related

Jface TreeSelection / StructuredSelection sort order

I am using the Eclipse Nebula GridTreeViewer which lets me access the selected items via a TreeSelection.
This works all good except for the sort order of the elements which are returned via StructuredSelection#iterator(). The sort order considers the order in which the elements were actually selected (e.g. when pressing Ctrl button for multi selection).
What I would need is the top=>down order of the elements as they are shown on the GUI.
I tried sorting the selection and then re-selecting with the new order. But unfortunately, the selection seems to be only updated if the actually selected elements change.
Does anyone know any other way to do this?

Sort Label values on an axis in Bar Chart

I'm trying to create a Bar chart for a Survey Question. The Survey Question has the possible options
Strongly Agree
Agree
Neither Agree nor Disagree
Disagree
Strongly Disagree
N/A
I would want the same order of the labels on the Scale as well. The Sort properties available in Visualization properties are:
Sort by Value, Sort bar segments by value, Reverse bar segment order
Can anyone please help me over here by lending a hand?
In Spotfire you can't set up custom sort in visualization, need to do it for the column itself, and all visualizations referring to that column will follow it.
Go to:
edit
column properties
select the column you want to sort
select "sort order" tab
select "custom sort order"
click "configure"
official help: https://docs.tibco.com/pub/spotfire/6.5.3/doc/html/data/data_details_on_custom_sort_order.htm

Exjts 4.2 get sort direction in headerclick

i am now want to get the grid column sorting direction for me to customized the sort function. May i know how i can have the sort direction in the below headerclick function.
headerclick: function(header, column, e, t,eOpts)
The grid column sorting indicator is only UI to sorters that are implemented at store level. You can access the sorters by grid.getStore().getSorters().

How to show the categoried column values if user click to sort the view

I have a view panel displaying a categorized view, all my columns are sortable.
When I click to sort one of the not categorized columns the values in categorized columns are not displayed. this is normal behaviour for a sorted categorized view in IBMNotes client as well.
The problem is that I need the category values to display if the view is sorted (clicked on sort icon) or display another column containing the category values, but only if the view is sorted.
How can I accomplish this?
First option: use more views with different sort setting in columns after category column. Dynamically change the view name. This works as you want, but it has performance impact on server and I don't recommend it.
Second option: use hide when on redundant (flat) column based on sort options. Exact formula depends on your implementation (submit page code).

extjs 4 How to change ordering of shown column dropdown on grid

Using extjs 4.1.1
I have a grid with lots of columns >20.
Initially, most of these columns are hidden.
If a user wants to unhide the column, they select the menu on any column, then select the "columns" choice, this expands another dropdown/dropout which shows all of the columns. Those with checkboxes next to them are shown.
My issue is this:
The columns in the dropdown are shown in the order in which they are defined/displayed in the grid. The order in which they are displayed in the grid has been chosen for a good reason( e.g. id as the first column). However, when a user wants to display one of the hidden columns, it is hard for them to find it in the list. This is because the list is sorted in the order the columns are defined. I want to sort the column dropdown/dropout list in alphabetical order, without effecting the order of the columns in the grid.
How can this done?
I think I found the solution to your question.
First of all I don't have the Ext JS 4.1.1. framework on my current PC. So I tried to figure out you problem reading the Ext JS 4.1.3. documentation available on Sencha's site. But I don't think that they have made drastical changes in this part of the framework between the two minor releases so my solution should work in your case too.
I have tried out my solution using JSFiddle. Unfortunately they did not have the 4.1.1. ext-all.css file, so I have linked manually the 4.0.2 file available at Sencha, so the menu is looking a bit missplaced.
The header menu and it's submenus are managed by the Ext.grid.header.Container class. The column submenu is constructed by the getColumnMenu method. The whole menu is purged and reconstructed on every drag and drop or other event which should affect the grid view. As a result it is enough to overwrite this method in order to solve the problem. Because the headercontainer class is too deep in the framework it is hard to extend it, so you have to make use of the Ext.base.override method.
The column submenu's menu items are created from the result of the
items = headerContainer.query('>gridcolumn[hideable]')
query. So you have to first sort alphabetically the result, before creating the menu items. I have added to the class the sortColumns method which does all the sorting stuff.
So here is what I did: link to my solution.
I hope that this is what you were looking for.

Resources