:: Forum >>

Serious sorting BUG but should be easy to fix

I ran into a bug and it should be very easy to fix for those with the tools. I have reproduced it easily with the "basic" grid example. Bring up the example and sort according to "Company Name". It sorts just fine.

Now, delete "Microsoft Corporation" (if it were only that simple ;-) ) so that it is an empty string (""). It actually does not sort correctly . . . an empty string should be at the top of the list when sorted ascending.

To illustrate the problem even better, you "Microsoft Corporation" back in and delete "Oracle Corporation" (the second item). Now sort and see the order completely messed up. You will see the order (first letter) as "", A, S, K, A, B, M, I, C, C, etc. Obviously, it is not in the correct order.

Different variations of empty strings will give different interesting results. A quick fix to this will be greatly appreciated.
Dyme
Friday, March 11, 2005
Incidentally, if I change the empty string(s) to be one space (" "), it works just fine.
Dyme
Friday, March 11, 2005
Does anyone have any clues on this?
Dyme
Wednesday, March 23, 2005
Is this the same problem reported in?
http://www.activewidgets.com/javascript.forum.1788.18/bug-caused-by-sorting.html
Dyme
Friday, March 25, 2005
Sorry for the delay with this bug. I can suggest a workaround:

http://www.activewidgets.com/grid.howto.fix/sort-empty-cells.html

Alex (ActiveWidgets)
Friday, March 25, 2005
That worked great. This also allowed me to sort case insensitive as well. Thank you!
Dyme
Friday, March 25, 2005
Will the link <A href=..> in a cell mess up the sort?
I have a page full of Counts (number or empty), it won't sort, not even for column with cells all have numbers.

I have tried the suggestion in "sort-empty-cells.html", it didn't help.

Please see my Script (sorry it's a little bit long), hope you can offer solution
========================================
<SCRIPT LANGUAGE='JavaScript' SRC='/trn/grid.js'></SCRIPT>
<script>
var obj = new Active.Controls.Grid;
var model = obj.getSelectionModel();

function showTransDetail(agt,code){
parent.BottomRptFrame.location.href='.../cgi-bin/realmkt/agentPipeline.cgi?agentid='+agt+'&StageCode='+code;
}

// for sorting Agent#
function string(text){return text};
function numb(text){return Number(text)};


// data source
var myData = [['<A Href="#" onClick="showTransDetail(2001,999)">Total</A>', '<A Href="#" onClick="showTransDetail(2001,20)">1</A>', '<A Href="#" onClick="showTransDetail(2001,30)">8</A>', '<A Href="#" onClick="showTransDetail(2001,40)"></A>', '<A Href="#" onClick="showTransDetail(2001,50)">11</A>', '<A Href="#" onClick="showTransDetail(2001,60)">10</A>', '<A Href="#" onClick="showTransDetail(2001,70)"></A>'],[ '<A Href="#" onClick="showTransDetail(1000,999)"> 1000</A>', '<A Href="#" onClick="showTransDetail(1000,20)">0</A>', '<A Href="#" onClick="showTransDetail(1000,30)">2</A>', '<A Href="#" onClick="showTransDetail(1000,40)">0</A>', '<A Href="#" onClick="showTransDetail(1000,50)">0</A>', '<A Href="#" onClick="showTransDetail(1000,60)">2</A>', '<A Href="#" onClick="showTransDetail(1000,70)">0</A>' ],[ '<A Href="#" onClick="showTransDetail(1001,999)"> 1001</A>', '<A Href="#" onClick="showTransDetail(1001,20)">1</A>', '<A Href="#" onClick="showTransDetail(1001,30)">1</A>', '<A Href="#" onClick="showTransDetail(1001,40)">0</A>', '<A Href="#" onClick="showTransDetail(1001,50)">2</A>', '<A Href="#" onClick="showTransDetail(1001,60)">2</A>', '<A Href="#" onClick="showTransDetail(1001,70)">0</A>' ],[ '<A Href="#" onClick="showTransDetail(1002,999)"> 1002</A>', '<A Href="#" onClick="showTransDetail(1002,20)">0</A>', '<A Href="#" onClick="showTransDetail(1002,30)">2</A>', '<A Href="#" onClick="showTransDetail(1002,40)">0</A>', '<A Href="#" onClick="showTransDetail(1002,50)">0</A>', '<A Href="#" onClick="showTransDetail(1002,60)">2</A>', '<A Href="#" onClick="showTransDetail(1002,70)">0</A>' ],[ '<A Href="#" onClick="showTransDetail(2025,999)"> 2025</A>', '<A Href="#" onClick="showTransDetail(2025,20)">0</A>', '<A Href="#" onClick="showTransDetail(2025,30)">1</A>', '<A Href="#" onClick="showTransDetail(2025,40)">0</A>', '<A Href="#" onClick="showTransDetail(2025,50)">0</A>', '<A Href="#" onClick="showTransDetail(2025,60)">0</A>', '<A Href="#" onClick="showTransDetail(2025,70)">0</A>' ],[ '<A Href="#" onClick="showTransDetail(2028,999)"> 2028</A>', '<A Href="#" onClick="showTransDetail(2028,20)">0</A>', '<A Href="#" onClick="showTransDetail(2028,30)">0</A>', '<A Href="#" onClick="showTransDetail(2028,40)">0</A>', '<A Href="#" onClick="showTransDetail(2028,50)">4</A>', '<A Href="#" onClick="showTransDetail(2028,60)">0</A>', '<A Href="#" onClick="showTransDetail(2028,70)">0</A>' ],[ '<A Href="#" onClick="showTransDetail(2032,999)"> 2032</A>', '<A Href="#" onClick="showTransDetail(2032,20)">0</A>', '<A Href="#" onClick="showTransDetail(2032,30)">1</A>', '<A Href="#" onClick="showTransDetail(2032,40)">0</A>', '<A Href="#" onClick="showTransDetail(2032,50)">2</A>', '<A Href="#" onClick="showTransDetail(2032,60)">0</A>', '<A Href="#" onClick="showTransDetail(2032,70)">0</A>' ],[ '<A Href="#" onClick="showTransDetail(2033,999)"> 2033</A>', '<A Href="#" onClick="showTransDetail(2033,20)">0</A>', '<A Href="#" onClick="showTransDetail(2033,30)">1</A>', '<A Href="#" onClick="showTransDetail(2033,40)">0</A>', '<A Href="#" onClick="showTransDetail(2033,50)">0</A>', '<A Href="#" onClick="showTransDetail(2033,60)">4</A>', '<A Href="#" onClick="showTransDetail(2033,70)">0</A>' ],[ '<A Href="#" onClick="showTransDetail(2475,999)"> 2475</A>', '<A Href="#" onClick="showTransDetail(2475,20)">0</A>', '<A Href="#" onClick="showTransDetail(2475,30)">0</A>', '<A Href="#" onClick="showTransDetail(2475,40)">0</A>', '<A Href="#" onClick="showTransDetail(2475,50)">2</A>', '<A Href="#" onClick="showTransDetail(2475,60)">0</A>', '<A Href="#" onClick="showTransDetail(2475,70)">0</A>' ],[ '<A Href="#" onClick="showTransDetail(2477,999)"> 2477</A>', '<A Href="#" onClick="showTransDetail(2477,20)">0</A>', '<A Href="#" onClick="showTransDetail(2477,30)">0</A>', '<A Href="#" onClick="showTransDetail(2477,40)">0</A>', '<A Href="#" onClick="showTransDetail(2477,50)">1</A>', '<A Href="#" onClick="showTransDetail(2477,60)">0</A>', '<A Href="#" onClick="showTransDetail(2477,70)">0</A>' ]];
var cols = ['AgentId', 'Applied', 'Pre-Approved', 'Approved', 'Closing Scheduled', 'Closed', 'Sold to Investor'];

// create grid object

var row = new Active.Templates.Row;
// row.setEvent("ondblclick","showAgentInfo()");
obj.setTemplate("row", row);

// set number of columns/rows
obj.setColumnTexts(cols);
obj.setColumnCount(7);
obj.setRowCount(10);
obj.setDataText('-');

// link to cell text
obj.setDataText(function(i,j){return myData[i][j]});
var toValue = [string, numb, numb, numb, numb, numb, numb];

// set data value to converted text
obj.setDataProperty("value", function(i,j){
return toValue[j](myData[i][j]);}
);

// write control to the page

document.write(obj);
</script>

<style>
.active-controls-grid {height: 86%; font: menu;}

.active-templates-header { color: blue; border-right: 1px solid orange}
.active-templates-item { text-align: right; color: blue; }
.active-row-cell {border-right: 1px dotted #99ccff}

.active-scroll-top .active-box-item {background: #ccff99}
.active-scroll-left .active-box-item {background: #ffcc99}
.active-scroll-corner .active-box-item {background: #99ffcc}

.active-column-0 {width: 70px; font: bold;middle; text-align: left;}
.active-column-1 {width: 85px; font: bold; text-align: center;}
.active-column-2 {width: 90px; font: bold; text-align: center;}
.active-column-3 {width: 75px; font: bold; text-align: center;}
.active-column-4 {width: 110px; font: bold; text-align: center;}
.active-column-5 {width: 75px; font: bold; text-align: center;}
.active-column-6 {width: 130px; font: bold; text-align: center;}
</style>
Bruce Y
Friday, September 23, 2005
Actually, by putting the Value(MyValue) in <A Href="#MyValue" will resovle the sort problem.
Bruce Y
Tuesday, October 4, 2005
why not just have a click handler seperate and no link in the cell it self. I am presuming here you have a seperate array with the function data I know your way fixes this was just a idea.

var row = new Active.Templates.Row;
row.setEvent("onclick", function() {this.action("Click")});
obj.setTemplate("row", row);
obj.setAction("Click", function(src) {doDetail(src.getProperty("item/index"));});

function showTransDetail(row)
{
var param1=detail[row][0];
var param2=detail[row][1];
}

detail been an array of the stuff you passing into showTransDetail at the moment

this way the grid sort word be sorting the actual data not the link stuff as well.
J
Tuesday, October 4, 2005
Hello,

Any one help me How to drag items inside the list box usin javascript.

Thanks a lot.
Wednesday, January 18, 2006

This topic is archived.


Back to support forum

Forum search