Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by satyachalla on Apr 01, 2008 05:16
open dhtmlx forum
dhtmlGrid

Hi,

I am an employee of Razorsiht Software Solutions. We are using license version of dhtmlGrid.

we baught this from you people. Here I am loding the grid from normal HTML table, not thru xml file.

We are facing problems in column Custom Sorting.

I mailed You the same issue, long back. You guys replied and asked me to send the code sample.

Here I am attaching the code sample.

Appreciating your earlier response

thanks

satya



<html>
<head>

<!-- <link href="css/new_ana_style.css" rel="stylesheet" type="text/css"> -->
<!-- Added for DHTMLGrid Starts -->
<link rel="STYLESHEET" type="text/css" href="css/dhtmlgrid/dhtmlxgrid.css">
<script src="JavaScript/dhtmlgrid/dhtmlxcommon.js"></script>
<script src="JavaScript/dhtmlgrid/dhtmlxgrid.js"></script>
<script src="JavaScript/dhtmlgrid/dhtmlxgridcell.js"></script>
<script src="JavaScript/dhtmlgrid/dhtmlxgrid_start.js"></script> <!-- Added for Loading from HTML table -->
<script src="JavaScript/dhtmlgrid/dhtmlxgrid_mcol.js"></script> <!-- Added for Column Move inside Table -->

<script language="javascript">

//for removing dollar sign
function removeDollar(dollarVal)
{
if(dollarVal.indexOf('$')!=-1)
{
var x = dollarVal.indexOf('$');
x = x+1;
var y = dollarVal.length;
dollarVal = dollarVal.substring(x,y);
}
return dollarVal;
}


function sort_custom(a,b,order){
//var n=a.length;
//var m=b.length;
a = removeDollar(a);
b = removeDollar(b);
var n=a;
var m=b;
//alert('n = '+n+' m = '+m);
if(order=="asc")
return n>m?1:-1;
else
return n<m?1:-1;
}

function doOnLoad(tableName){
mygrid = new dhtmlXGridFromTable(tableName);
mygrid.setImagePath("./JavaScript/dhtmlgrid/imgs/");
mygrid.enableColumnMove(true); // Added for column move.
mygrid.enableColumnAutoSize(true); // Added for column resizing on Double Click.
}
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="doOnLoad('MyTableExceptionList');">
<!-- Grid Threshold Values-->
<!-- <DIV id="GridTech" > -->
<br><b> GRID FOR CUSTOM SORTING on Columns Containg $ i.e, Monthly Excepion Amount and Retro-Credit Amount </b> </br>
<br/>
<!-- Added for DHTMLGrid change Starts -->
<table width="100%" border="0" bordercolorlight="#000000" align="left"
cellpadding="0" cellspacing="0"
id="MyTableExceptionList"
gridHeight="100%"
hlcolor=#FED079
gridWidth="100%"
forceCellTypes="true" dragAndDrop="true">

<thead >
<tr valign="middle" class="TableHeaders" >
<td width="120" type="ro" sort ="str" align="left" class="tbl_hdr_left"> Audit Category </td>
<td width="230" type="ro" sort ="str" align="left" class="tbl_hdr_left">Audit Report </td>
<td width="120" type="ro" sort ="int" align="right" class="tbl_hdr_left"> Exception Count</td>
<td width="190" type="ro" sort ="sort_custom" align="right" class="tbl_hdr_left"> Monthly Exception Amount </td>
<td width="140" type="ro" sort ="sort_custom" align="right" class="tbl_hdr_left"> Retro-Credit Amount </td>
<td width="135" type="ro" sort ="str" align="left" class="tbl_hdr_right"> Exception Type </td>
<!-- Added for DHTMLGrid change Ends -->
</tr> </thead>

<tr align="left" valign="middle" bgcolor="#ffffff" class="columntext"
onMouseOver="">
<td height="19" class="tbl_cont_left01">Billed Charges Report</td>
<td class="tbl_cont_left01">

<a href="javascript:audit_click('15','Report of State Level Surcharge Costs','Billed Charges Report','79.21');">
Report of State Level Surcharge Costs
</a>

</td>
<td align="right" class="tbl_cont_left01">1</td>

<td align="right" class="tbl_cont_left01" >$79.21</td>
<td align="right" class="tbl_cont_left01">$0.00</td>
<td align="right" class="tbl_cont_right"> </td>
</tr>

<tr align="left" valign="middle" bgcolor="#ffffff" class="columntext"
onMouseOver="">
<td height="19" class="tbl_cont_left01">Invoice Charges Audit</td>
<td class="tbl_cont_left01">

<a href="javascript:audit_click('6','CT/EF at Same Location as CFA','Invoice Charges Audit','231.49');">
CT/EF at Same Location as CFA
</a>

</td>
<td align="right" class="tbl_cont_left01">1</td>

<td align="right" class="tbl_cont_left01" >$231.49</td>
<td align="right" class="tbl_cont_left01">$0.00</td>
<td align="right" class="tbl_cont_right"> </td>
</tr>

<tr align="left" valign="middle" bgcolor="#ffffff" class="columntext"
onMouseOver="">
<td height="19" class="tbl_cont_left01">Invoice Charges Audit</td>
<td class="tbl_cont_left01">

<a href="javascript:audit_click('33','Incorrect Facility Mileage Quantity','Invoice Charges Audit','545.08');">
Incorrect Facility Mileage Quantity
</a>

</td>
<td align="right" class="tbl_cont_left01">1</td>

<td align="right" class="tbl_cont_left01" >$545.08</td>
<td align="right" class="tbl_cont_left01">$0.00</td>
<td align="right" class="tbl_cont_right"> </td>
</tr>

<tr align="left" valign="middle" bgcolor="#ffffff" class="columntext"
onMouseOver="">
<td height="19" class="tbl_cont_left01">Invoice Charges Audit</td>
<td class="tbl_cont_left01">

<a href="javascript:audit_click('51','Incorrect billed amount due to an incorrect Ratchet, PIU or Quantity','Invoice Charges Audit','231.49');">
Incorrect billed amount due to an incorrect Ratchet, PIU or Quantity
</a>

</td>
<td align="right" class="tbl_cont_left01">1</td>

<td align="right" class="tbl_cont_left01" >$231.49</td>
<td align="right" class="tbl_cont_left01">$0.00</td>
<td align="right" class="tbl_cont_right"> </td>
</tr>

<tr align="left" valign="middle" bgcolor="#ffffff" class="columntext"
onMouseOver="">
<td height="19" class="tbl_cont_left01">Provisioned Inventory to Invoice Audit</td>
<td class="tbl_cont_left01">

<a href="javascript:audit_click('12','Billed Term Length Vs. Inventory Term Length','Provisioned Inventory to Invoice Audit','776.57');">
Billed Term Length Vs. Inventory Term Length
</a>

</td>
<td align="right" class="tbl_cont_left01">2</td>

<td align="right" class="tbl_cont_left01" >$776.57</td>
<td align="right" class="tbl_cont_left01">$0.00</td>
<td align="right" class="tbl_cont_right"> </td>
</tr>

<tr align="left" valign="middle" bgcolor="#ffffff" class="columntext"
onMouseOver="">
<td height="19" class="tbl_cont_left01">Provisioned Inventory to Invoice Audit</td>
<td class="tbl_cont_left01">

<a href="javascript:audit_click('71','Incorrect PIU or PLU on circuits based on what percentage was ordered','Provisioned Inventory to Invoice Audit','776.57');">
Incorrect PIU or PLU on circuits based on what percentage was ordered
</a>

</td>
<td align="right" class="tbl_cont_left01">2</td>

<td align="right" class="tbl_cont_left01" >$776.57</td>
<td align="right" class="tbl_cont_left01">$0.00</td>
<td align="right" class="tbl_cont_right"> </td>
</tr>

</table>
<!-- </div> -->
</body>
</html>
<!-- End od grid threshold Values -->

Answer posted on Apr 01, 2008 05:54
Problem caused by the way how removeDollar function works, it returns data as (string) , so all further operation process it incorrectly.
Just replace
    return dollarVal;
with
    return parseInt(dollarVal);


Meanwhile grid supports "price" excell which work nearly the same, but it compatible with native sorting