Number sorting - 1,2,3 instead of 1,10,2,3

18 posts by 8 authors in: Forums > CMS Builder
Last Post: November 29, 2010   (RSS)

By Jason - November 1, 2010

Hi,

Using "+0" is for when you have a number stored in a text field and yo want the sort to treat it as a number, not text. In your case, the field address contains both text and numbers. The sorting isn't going to sort your records based on different parts of that field (ie, putting Unit F123 before Unit F5) as it will just look at the beginning of the text.

The closest approximation to what you're trying to achieve would be to use 'orderBy' => 'suburb, address DESC', and just let it sort the field alphabetically. Another opton would be to use dragSortOrder to manually order these records.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Number sorting - 1,2,3 instead of 1,10,2,3

Hi Jason
How does the dragSortOrder (ie, what do I need to code in to use this option).

Thanks

Re: [Jason] Number sorting - 1,2,3 instead of 1,10,2,3

Hi Jason

I have done this:
At the the top of the field list enter the following for "Quick Add" field:
Field Label: dragSortOrder
Field Type: None
Field Name: dragSortOrder

Next, click the "General" tab and add this to the beginning of "ListPage Fields":
dragSortOrder,

Then click the "Sorting" tab and add this for "Order By":
dragSortOrder DESC

Then click "Save".

And deleted the OrderBy on the php file, ie,
// load records
list($lease_warehouseRecords, $lease_warehouseMetaData) = getRecords(array(
'tableName' => 'lease_warehouse',
));

// load records
list($lease_summary_introRecords, $lease_summary_introMetaData) = getRecords(array(
'tableName' => 'lease_summary_intro',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$lease_summary_introRecord = @$lease_summary_introRecords[0]; // get first record

But it's not ordering them according to my dragSortOrder - see. Any clues?

By Jason - November 2, 2010

Hi,

Try this:

// load records
list($lease_warehouseRecords, $lease_warehouseMetaData) = getRecords(array(
'tableName' => 'lease_warehouse',
'debugSql' => true,
));

// load records
list($lease_summary_introRecords, $lease_summary_introMetaData) = getRecords(array(
'tableName' => 'lease_summary_intro',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
'debugSql' => true,
));


This will output the SQL query to the screen so you can see exactly what it is searching on. You should see dragSortOrder in the where clause. If you do, and it's not sorting on it, it may be that those fields don't have any values since you just created it. Try moving your records around and see if that makes any difference.

If you don't see dragSortOrder in the where clause at all, you should fill out a 2nd Level Support Request here:
https://www.interactivetools.com/support/email_support_form.php

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Number sorting - 1,2,3 instead of 1,10,2,3

I added the 'debugSql' => true,[/#ff0000] however it added a string of error message to the top of the live page. It's not working.

There are two issues:

1. I keep resorting the order in the Admin section, but it doesn't retain the order

2. The public display of the order doesn't seem to change at all when I resort by manually dragging the ordered list in the cmsAdmin panel.

I have added dragSortOrder DESC in the sorting tab, but it doesn't look like it's having any impact whatsoever. Any ideas?

PS. What are the tick boxes for in the cmsAdmin for the drag sort order. Do I need to tick them all or ??????????

By Jason - November 25, 2010

Hi,

It sounds like something else is going on here. If you could fill out a [url http://www.interactivetools.com/support/]2nd Level Support Request[/url] I can go in and take a closer look into this issue for you.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By Jason - November 29, 2010

Hi,

I've tracked down this issue. The dragSortOrder was working, what was happening was part way down the file you have an include file called propertyDropDown.php that used the same variable name ($lease_warehouseRecords) for it's dropdown menu. This list, however, was sorted by suburb, not dragSortOrder. The version of the variable in propertyDropDown.php was overwriting the variable you created at the top of your list page. I went in and renamed the variable in your include file. Everything seems to be working the way we would expect now.


Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/