3.2.0

Date sorting is possible in version 1.0.2 ?

Columns containing date field in any format is not sorted at all.
My grid contains three field of which last is a date of format "dd mm yyyy". I have populated grid from database data i.e. javascript array.exerpts of code is as follows.

var obj = new Active.Controls.Grid;

var date1 = new Active.Formats.Date;
var string = new Active.Formats.String;
date1.setDataFormat("auto");
date1.setTextFormat("dd mmm yyyy");
var formats=[String,String,date1];
obj.setRowCount(<%=rowCount%>);
obj.setColumnCount(<%=colCount%>);

obj.setCellData(myData); //myData is javascript array

obj.setCellFormat([string,string,date1]);//error gives here
/*
Object does not support this method or property.
*/

obj.setColumnText(function(i){return myColumns[i]});//myColumn is javascript array for column header

document.write(obj);

I have searched the forum a lots but no there is no solution to this problem.Even in some downloaded example(which comes with downloaded bundle) all the values of date field are same date so that don't have to sort. I really wonder the grid can sort the date field or not.

Please help....
Mrinmoy
July 14,
<script>
var myData = [["MSFT","Microsoft Corporation", "01/12/1981", "32,187.000", "55000"],
["ORCL", "Oracle Corporation", "01/01/1980", "9,519.000", "40650"],
["SAP", "SAP AG (ADR)", "24/06/1944", "8,296.420", "28961"],
["CA", "Computer Associates Inter", "01/01/1982", "3,164.000", "16000"],
["ERTS", "Electronic Arts Inc.", "01/01/1999", "2,503.727", "4000"]];

var myColumns = ["Ticker", "Company Name", "DATE", "$ Sales", "Employees"];

// create ActiveWidgets Grid javascript object
var obj = new Active.Controls.Grid;

var string = new Active.Formats.String; 
var date  = new Active.Formats.Date; 

date.setDataFormat("auto"); 
date.setTextFormat("dd/mm/yyyy"); 
obj.setRowCount(myData.length); 
obj.setColumnCount(myColumns.length); 
var formats = [string,string,date,string,string]; 
             
obj.setDataText(function(i, j){return formats[j].dataToText(myData[i][j])}); 
obj.setDataValue(function(i, j){return formats[j].dataToValue(myData[i][j])}); 
  
// write grid html to the page
document.write(obj);

</script>
Carlos
July 14,
Carlos,

thanx for your reply.
I have followed what you said.My code is as follows.

var obj = new Active.Controls.Grid;
    
    var date = new Active.Formats.Date;
    var string = new Active.Formats.String;  
    date.setDataFormat("auto");
    date.setTextFormat("dd/mm/yyyy");
     

    var formats=[string,string,date];

    //	set number of rows/columns
    obj.setRowCount(<%=rowCount%>);
    obj.setColumnCount(<%=colCount%>);
    
        
    obj.setDataText(function(i, j){return formats[j].dataToText(myData[i][j])});  
    obj.setDataValue(function(i, j){return formats[j].dataToValue(myData[i][j])});  

    obj.setColumnText(function(i){return myColumns[i]});

        document.write(obj);


the list shows but the date field shows #ERR value. What is the remedy
of this?
regards
Mrinmoy
Mrinmoy
July 15,
Seems to be date mistmatch format.
if your dates are stored like:
var myData = [["MSFT","Microsoft Corporation", "01-12-1981", .....
then the format to apply is:
date.setTextFormat("mm-dd-yyyy");
HTH
Carlos
July 15,
Upps! , sorry not exactly true, it not depends on date separator date.setTextFormat defines the separator to display.
But be sure your data arrives in a formated (2dig+anyseparator+2d+as+4d) Note: no time or month in text 3 dig like 'May'.
HTH
Carlos
July 15,
Also check the correct day-month format (dd-mm ... or mm-dd
July 15,
Carlos,
finally I solved it.Thanx for your help.
I have changed the database date datefield format from dd/mm/yyyy to dd-mm-yyyy. Now sorting works well.
Mrinmoy
July 19,
Hi,

I have found a work around for date sorting. What ever maybe the date format, Change the date format to YYYYMMDD and put this value in a dummy hidden field (i.e <input type=hidden value="YYYYMMDD">) and the hidden field should be in the begining of the field. The sorting works perfectly fine.

EX-
myCol0=["NAME","DATE OF BIRTH(DD/MM/YYYY)"]

myData0=[
["Prem","<input type=hidden value="19770110">10/01/1977"],
["Arun","<input type=hidden value="19700321">21/03/1970"],
["Venk","<input type=hidden value="19670216">16/02/1967"]
]

This should solve your problem

I am not a frequent visitor to this forum. you can mail me at premlibra@gmail.com
Prem Sekhar
January 29,

This topic is archived.

See also:


Back to support forum