Opened 7 years ago

Closed 7 years ago

#15918 closed defect (patchwelcome)

dojox.grid.cells.DateTextBox does not handle datePattern

Reported by: daf182 Owned by: Evan
Priority: undecided Milestone: tbd
Component: DojoX Grid Version: 1.6.0
Keywords: Cc:
Blocked By: Blocking:

Description

When I use dijit.form.DateTextBox? I can specify the datePattern constraint as widget attribute. However this is not possible with dojox.grid.cells.DateTextBox? used inside grid cells.

The original dojox.grid.cells.DateTextBox? widget only takes the date argument (as String) received from the grid's store and pass it to the Date constructor: (dojox/grid/cells/dijit.js, linenumber 158) dojo.declare("dojox.grid.cells.DateTextBox?", dgc._Widget, {

widgetClass: dijit.form.DateTextBox?, setValue: function(inRowIndex, inValue){

if(this.widget){

this.widget.set('value', new Date(inValue)); this is the problem

}else{

this.inherited(arguments);

}

}, getWidgetProps: function(inDatum){

return dojo.mixin(this.inherited(arguments), {

value: new Date(inDatum) this is the problem

});

}

});

I came up with a workaround as follows: dojo.declare("my.domain.grid.cells.DateTextBox?", dojox.grid.cells.DateTextBox?, {

widgetClass: dijit.form.DateTextBox?, setValue: function(inRowIndex, inValue){

if(this.widget){

var date = this._createDateByPattern(inValue); this.widget.set('value', date);

}else{

this.inherited(arguments);

}

}, getWidgetProps: function(inDatum){

var date = this._createDateByPattern(inDatum); return dojo.mixin(this.inherited(arguments), {

value: new Date(date)

});

}, /

  • Parent DateTextBox? component does not handle datePattern constraint. */

_createDateByPattern : function (/*String*/ date) {

var pattern = "d/M/yyyy"; if (this.constraints && this.constraints.datePattern) { pattern = this.constraints.datePattern; } return dojo.date.locale.parse(date, {selector: 'date', datePattern: pattern});

}

});

This pattern I have to use is not supported by Date constructor, and a semi random Date is returned. Eg: new Date("23/11/2012") results -> Date {Mon Nov 11 2013 00:00:00 GMT+0100 (Central Europe Standard Time)}

So the date displayed in my grid cells has to be parsed by dojo.date.locale.parse() to get the proper Date object.

Change History (2)

comment:1 Changed 7 years ago by bill

DojoX Grid and EnhancedGrid are deprecated in favor of dgrid and gridx.

You should upgrade your code to use one of those two grids.

We will consider patches to the old DojoX Grid code though.

comment:2 Changed 7 years ago by bill

Resolution: patchwelcome
Status: newclosed
Note: See TracTickets for help on using tickets.