error123456789
error123456789

Reputation: 1079

ExtJS--set textfield value to first of the month

I am trying to default the value of a textfield to the first of the current month

{
  xtype:"textfield",
  fieldLabel:"Effective Date",
  name:"effDate",
  labelAlign:"top",
  editable:false,
  value: Ext.Date.getFirstDateOfMonth()//throws error saying cannot read property "getFullYear" of undefined
}

Upvotes: 0

Views: 153

Answers (2)

Guilherme Lopes
Guilherme Lopes

Reputation: 4760

If you are trying to get the first date of the current month, you should add new Date() as a parameter.

{
    xtype:"textfield",
    fieldLabel:"Effective Date",
    name:"effDate",
    labelAlign:"top",
    editable:false,
    value: Ext.Date.getFirstDateOfMonth(new Date())
}

Upvotes: 1

Igor Semin
Igor Semin

Reputation: 2496

You must pass date to this function

value: Ext.Date.getFirstDateOfMonth(new Date()) // for example

Fiddle

Upvotes: 2

Related Questions