PDA

View Full Version : disabled dates



lobosan
5 Aug 2013, 5:04 PM
Hi everyone,

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


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},{"id":9,"dias_laborables":"2013-08-07","disponible":false},{"id":19,"dias_laborables":"2013-08-19","disponible":false}]}


what I want to get is something like this


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


instead of


[]







0
"2013-08-10"



1
"2013-08-15"



2
"2013-08-07"



3
"2013-08-19"



remove
function()



__proto__
[]






I hope someone can help me

willigogs
6 Aug 2013, 12:59 AM
Something like this? (untested)


var storeFechasOcupadas = new Ext.data.JsonStore({
url: 'modules/citas/agendar/server/crudAgendar.php?operation=fechasOcupadas',
root: 'data',
id: 'id',
fields: ['dias_laborables'],
listeners: {
load: function(store, records, options) {
var disabledDates = [];
Ext.each(records, function(rec, i) {
var disabled = rec.get('dias_laborables');
disabledDates.push(disabled)
})
Ext.getCmp('your-datefield-id').setDisabledDates(disabledDates)
}
}
});

lobosan
6 Aug 2013, 4:52 AM
Thank you very much Willigogs you saived my life it works like a charm =D>

javapurna
23 Dec 2013, 10:37 PM
setDisabledDates(disabledDatesArray);

working fine for me. Thank you