Basic List Ordering Issues

  • 19 February 2015
  • 2 replies
  • 0 views

Badge +10

HI all,

 

Im having a very strange issue with list ordering with the K2 list view. Now I have a list view that has about 4 coloumns which are strings and one more coloumn whcih is "Created Date". Now, I have a list method for that list view that  lists and populates this data. All is fine up to now, In the list rule, I have set the sort option to the "Created Date" coloumn and in ascending order. Now this part is not happening.  It is not sorting the list view in ascending order of the "Created Date" coloumn.

 

Even more strangely, the same list view works perferct in my development machine but once deployed to aother environment, it doesn't order the list.

There is not much to go on debugging as this is such as simple thing so any advice would e great.

 

I would also like to add that if i actually click on the "Created Date" coloum it orders it perfectly. However, I would like it to order from the get go without having to click on the coloumn to order it.

 

Thanks

 

 

 

 


2 replies

Userlevel 1
Badge +8

Hi s0m3one

 

Can you advise what Service Instance type the smartobject is derived from (e.g. SQL Server, Smartbox, etc). If it is SQL, are you using the standard List method or have you created a custom method?

 

Just to confirm - the sorting is working as expected in the dev environment but not another?

 

Does the data get returned in the correct sort order in the SmartObject tester (when you add the sort by date) in both environments?

 

 

Badge +10

Thanks for your reply.

 

I have found what is causing the problem but don’t have a solution at the moment. I am using a custom service object and the backend is microsoft sql server. This created date field is a date and time in the database. In the smartobject and service object this is converted into a string. I remember now that it was made into a string because the list view would not render a date field. It would only render a string. Now, it looks like this is the problem, its just ordering as a string so if you have for example; 20/01/2015 and 19/03/2015 returned by the smartobejct as a string. We know that the second date is later than the first date but. The list view will render it wrong way round because it will look at the first letter and works out 2 is greater than 1. Here lies the problem.

 

I have tried to sort the list when it is a date in the service object before returning them but for some reason its reordering the list when run through the smartobject tester. I have removed the sort rule in the view itself.

 

To answer your question, Initially I thought this worked in my development machine but it does not, It was just coincidence that the date seemed to match the string ordering.

 

@Update: Issue resolved. Not entirely sure why the service object level ordering was not working before, now its ordering correctly. Maybe, the dll didnt update when I first tried.

 

Reply