0

Can someone please help me. I'm trying to assign dynamically the value of disabledDates attribute of my datefield

xtype: 'datefield',
disabledDates: disabledDates

This is the code to get the store and build the dynamic "disabledDates" array

var storeFechasOcupadas = new Ext.data.JsonStore({
     url: 'modules/citas/agendar/server/crudAgendar.php?operation=fechasOcupadas',
     root: 'data',
     id: 'id',
     fields: ['dias_laborables']
 });

 var disabledDates = [];
 storeFechasOcupadas.load({
      callback: function(record, operation, success) {
            for (var i = 0; i < record.length; i++) {
                 disabledDates.push(record[i].data['dias_laborables']);
             }
       }
  });

The store response is like this

{"success":true,"data":[
    {"id":12,"dias_laborables":"2013-08-10","disponible":false},
    {"id":16,"dias_laborables":"2013-08-15","disponible":false}
]}

what I want to get is something like this

disabledDates = ["2013-08-10","2013-08-14","2013-08-15"]

but what I see with console.log(disabledDates)

[]
0   "2013-08-10"
1   "2013-08-15"
2   "2013-08-07"
3   "2013-08-19"
remove  function()
__proto__   []

and even if I try to get disabledDates[0] it returns undefined

Thanks in advance for any help

Lobosan
  • 135
  • 2
  • 13

1 Answers1

0

The most likely scenario is that your date field is already constructed before the data from the Ajax request is returned. Try creating your form inside the store load event after the array is actually filled.

Evan Trimboli
  • 29,900
  • 6
  • 45
  • 66
  • Hi Evan, thanks for your time. The disabledDates array is available before the creation of the form. The problem I have is that I can get this structure ["2013-08-10","2013-08-14","2013-08-15"], instead I'm getting the object [] 0 "2013-08-10" 1 "2013-08-15" – Lobosan Aug 06 '13 at 03:36