DateFormat is not working in GRID
I have following code and date format in display of grid is not working,
Can any one guess what's happening?
Also I have common code where i m formating cell as following:
and HTML code is below.
Can any one guess what's happening?
function addrowsX(date){
for (var i = 0; i < 10; i++)
{
var schedulePeriod = i + 1;
var startDate = new Date(date);
startDate.setMonth(startDate.getMonth() + i);
var endDate = new Date(startDate);
endDate.setMonth(endDate.getMonth() + 1);
endDate.setDate(endDate.getDate() -1);
grdSwapSchedule.data[grdSwapSchedule.data.length] = [0,schedulePeriod, startDate, endDate, 'N'];
grdSwapSchedule.addRow(grdSwapSchedule.data.length - 1);
}
}
Also I have common code where i m formating cell as following:
/*
* Converts the specified table to an Active Widgets grid.
*/
function convertTable(table)
{
var dateFormat = new AW.Formats.Date();
dateFormat.setTextFormat("dd-MMM-yyyy");
var numberFormat = new AW.Formats.Number();
var stringFormat = new AW.Formats.String();
var columns = new Array();
var formats = new Array();
var displayColumnIndices = new Array();
var headerRow = table.rows[0];
for (var i = 0; i < headerRow.cells.length; i++)
{
columns[i] = headerRow.cells[i].innerHTML;
if (headerRow.cells[i].getAttribute('format') == 'date')
formats[i] = dateFormat;
else if (headerRow.cells[i].getAttribute('format') == 'number')
formats[i] = numberFormat;
else
formats[i] = stringFormat;
if (headerRow.cells[i].className != 'hidden')
displayColumnIndices[displayColumnIndices.length] = i;
}
var rowClickListeners = new Array();
var rowDoubleClickListeners = new Array();
var tooltips = new Array();
var data = new Array();
//Fixes bug where empty data causes a bug when adding new rows.
//http://www.activewidgets.com/javascript.forum.16361.2/bug-in-addrow-if-datasource.html
var deleteFirstRow = true;
data[0] = new Array();
for (var i = 0; i < columns.length; i++)
data[0][i] = '';
for (var rowIndex = 1; rowIndex < table.rows.length; rowIndex++)
{
deleteFirstRow = false;
var row = table.rows[rowIndex];
data[rowIndex - 1] = new Array();
for (var colIndex = 0; colIndex < row.cells.length; colIndex++)
data[rowIndex - 1][colIndex] = row.cells[colIndex].innerHTML;
if (row.getAttribute('tooltip'))
tooltips[rowIndex - 1] = row.getAttribute('tooltip');
rowClickListeners[rowIndex - 1] = row.onclick;
if (row.getAttribute('onclick'))
rowDoubleClickListeners[rowIndex - 1] = new Function('event', 'index', row.getAttribute('onclick'));
if (row.getAttribute('ondoubleclick'))
rowDoubleClickListeners[rowIndex - 1] = new Function('event', 'index', row.getAttribute('ondoubleclick'));
}
var grid = new AW.UI.Grid();
grid.data = data;
grid.setId(table.id);
grid.setVirtualMode(table.getAttribute('virtual') != 'false');
grid.setSelectionMode(table.getAttribute('selectionMode'));
grid.setHeaderText(columns);
grid.setCellFormat(formats);
grid.setCellText(data);
grid.setColumnCount(displayColumnIndices.length);
grid.setRowCount(data.length);
grid.tooltips = tooltips;
grid.setCellTooltip(function(col, row){return this.tooltips[row] ? this.tooltips[row] : '';});
if(table.getAttribute('headerSorting') == 'false') grid.onHeaderClicked = function(){ return true;};
grid.rowClickListeners = rowClickListeners;
grid.onRowClicked = function(event, index){if (this.rowClickListeners[index]) this.rowClickListeners[index](event, index);};
grid.onRowShiftClicked = function(event, index){if (this.rowClickListeners[index]) this.rowClickListeners[index](event, index);};
grid.rowDoubleClickListeners = rowDoubleClickListeners;
grid.onRowDoubleClicked = function(event, index){if (this.rowDoubleClickListeners[index]) this.rowDoubleClickListeners[index](event, index);};
grid.onRowShiftDoubleClicked = function(event, index){if (this.rowDoubleClickListeners[index]) this.rowDoubleClickListeners[index](event, index);};
var parentNode = table.parentNode;
parentNode.removeChild(table);
parentNode.innerHTML = grid;
//See work around for bug detailed above.
if (deleteFirstRow)
{
grid.deleteRow(0);
grid.setRowState('deleted', 0);
}
//DO NOT MOVE THIS - setting it before the grid is displayed causes an error - NH 4/2007.
grid.setColumnIndices(displayColumnIndices);
return grid;
}
and HTML code is below.
<table
id="swapSchedule"
class="AWTable"
selectionMode="single-row"
virtual="false"
headerSorting="false"
>
<tr>
<th format="number">id</th>
<th format="number">Scheduled Period</th>
<th format="date">Start Date</th>
<th format="date">End Date</th>
<th>Extra Ordinary Period</th>
</tr>
</table>
Naresh C
May 20,