Dropdown list getting sorted by default in ascending order.

  • 28 August 2017
  • 3 replies
  • 141 views

Hi,

 

My requirement is to display year values in a dropdown as Current year,Next year and Previous year.

 

Eg:2017, 2018, 2016

 

Issue: Without specifying the sorting order, the values get sorted in asec. Moreover there are only two options for sorting either Ascending or Descending. I want data to be displayed the way it is returned from DB.

 

Any help would be appreciated!


3 replies

Badge +8

Ramya,

 Generally on a dropdown when using a smartobject as a source the dropdown menu will display in the order of the database. You can always create a view of the SQL Table and order it how you want. The great thing about using a view on a SQL table is the view can be changed when needed without altering the main table. Another way we have accomplished this is by adding a sort order column to the SQL table so that we could order by the sort order column. I would not reccoment this for large tables but if it is a reference table with minimal entries it should be fine.

 

Thanks,

Bryan Peters

Hello,


 


Unfortunately, there is not a way to do this Out of the Box in K2. SQL might be able to handle this. However, this would make a great feature request. Feel free to add it to our Ideas page.


https://ideas.k2.com/

Hello, I was facing same problem and since you cannot use "order by" clause in SQL view, I have searched furher and found solution in older thread here: https://community.k2.com/t5/K2-Blackpearl-Forum-Posts/Is-it-possible-to-change-the-sort-order-for-a-drop-down-list/m-p/56081. 

Reply