xGrid sort an issue on column 1

Management noticed that the grid is sorting column 1 incorrectly (and seeminly randomly)



The grid is created as:

grdSearchResults = new dhtmlXGridObject(‘grdSearch_Results_Container’)

grdSearchResults.setImagePath(“images/grid_images/”);

grdSearchResults.setHeader(“Vendor Name,Lead Time,Minimum,Estimated Price,Delivery Charge”);

grdSearchResults.setInitWidths(“290,90,85,125,120”);

grdSearchResults.setColAlign(“left,center,center,center,center”);

grdSearchResults.setSkin(“xp”);

grdSearchResults.setColTypes(“ro,ro,ro,ro,ro”);

grdSearchResults.setColSorting(“str,str,str,str,str”)

grdSearchResults.init();



It is then fill with these temp values:

gridAddRowSearch(“Tonys Italian Cuisine”,“30-40 min”, “$10.00”,"$21-30","$0.00");

gridAddRowSearch(“Daisys BBQ”,“20-30 min”, “$15.00”,"$21-30","$7.00");

gridAddRowSearch(“5 Napkin Burger”,“30-40 min”, “$20.00”,"$21-30","$0.00");

gridAddRowSearch(“Mortons”,“10-40 min”, “$40.00”,"$41-50","$5.00");

gridAddRowSearch(“Pizza Heaven”,“30-40 min”, “$20.00”,"$21-30","$5.00");



Here is that function

function gridAddRowSearch(sRestaurant,sLeadTime,mMinimum,sEstimatedPrice,mDeliveryCharge) {

var sStyle = “color:#58585a;font-family:Arial;font-weight:normal;font-size:10pt;”;

var iRow = (grdSearchResults.getRowsNum() + 1);

var sURL

var sFunction

var sTitle = “Restaurant detail info to go here” //There is an issue with title, maybe because of the mouseover





sTitle = replaceAll(sTitle, " “, sSpace);

sRestaurant = replaceAll(sRestaurant, " “, sSpace);

sFunction = “showRestaurantPopup(\’”+iRow+”\’,\’”+sRestaurant+"\’);";



sURL = “<a href=’#’ style=‘color:#58585a;font-family:Arial;font-weight:normal;font-size:10pt;text-decoration:none;’ onclick=‘selectRestaurant();’ onmouseover=setTimeout(’”+sFunction+"’,1000)>"+sRestaurant+""

grdSearchResults.addRow(iRow,[sURL,sLeadTime,mMinimum,sEstimatedPrice,mDeliveryCharge]);

grdSearchResults.setRowTextStyle(iRow, sStyle);

}





Columns 2 through 5 sort correct.



However, for column 1 I get (asc)

Pizza Heaven

Mortons

5 Napkin

Daisys BBQ

Tonys Italian Cuisine



sorted desc

Tony’s Italian Cuisine

Daisys BBQ

5 Napkin

Mortons

Pizza Heaven



I assume this might be something to do with the url code… but the url is, currently, the same for each line.



Thanks kindly,

James


While sorting grid takes getValue() from the cell and sort grid based on this values. In your first column getValue() cell’s method will return strings:


"<a href=’#’ style=‘color:#58585a;font-family:Arial;font-weight:normal;font-size:10pt;text-decoration:none;’ onclick=‘selectRestaurant();’ onmouseover=setTimeout(’"+sFunction+"’,1000)>Tonys Italian Cuisine"
"<a href=’#’ style=‘color:#58585a;font-family:Arial;font-weight:normal;font-size:10pt;text-decoration:none;’ onclick=‘selectRestaurant();’ onmouseover=setTimeout(’"+sFunction+"’,1000)>Daisys BBQ"
etc.




In you case better to implement custom eXcell type and redefine getValue() methos which will return necessary string. Please see more information here dhtmlx.com/docs/products/dhtmlxG … #grid_cexc