inane
inane

Reputation: 648

Set the value to the datepicker from a json

I am trying set the value to datepicker component under Sencha Touch from a store with the next code :

    setRDDConfigs: function () {
    var store = Ext.getStore('OrderOptions');
    var cartHeaderRDD = this.getHeaderRDD();

    Ext.each(store.getRange(), function (record) {
        var r = record.getData().rdd;
        var formatted = c.Helper.formatSAPdate2Str(r);
        console.log(r); // here  20140807  for example
        console.log(formatted); // here 07-08-2014
        cartHeaderRDD.setValue(new Date(r)); // NAN
        //cartHeaderRDD.setValue(formatted); //NAN
    });
},

In the view:

{
  xtype: 'CustomDatepicker',
  itemId: 'headerRDD',
  name: 'rdd',
  required: true,
  hidden: true
},

But it isn´t working properly.. what am i doing wrong??

Thanks!

Upvotes: 2

Views: 1292

Answers (2)

And-y
And-y

Reputation: 1524

Try the following

parsedDate = Ext.Date.parse(r, "Y-m-d");
cartHeaderRDD.setValue(parsedDate);

Ext.Date.parse takes a String as first input and the format as the secound. The Result is a Date object if parsing was successfull or null if not.
Change the format according to your format in r.

For more informations see http://docs.sencha.com/extjs/5.0.1/#!/api/Ext.Date-method-parse .

Upvotes: 1

Sujata Chanda
Sujata Chanda

Reputation: 3395

You need to set the date in setValue like this:

 cartHeaderRDD.setValue(new Date());

Upvotes: 1

Related Questions