Disabling dates in an ExtJS calendar

I want to disable certain dates in my calendar. I have code to do this, but in this code the dates are statically loaded. I need to retrieve the list of dates from my database.

I know how to retrieve the data from my database, but I don't know how to pass it from the store to the view array. Can anyone help me to resolve it?

dateArray = ["06/17/2007","06/01/2007","05/17/2007","05/01/2007"];

dateField = new Ext.form.DateField({
            format:"m/d/Y",
            disabledDates:["^("+dateArray.join("|")+").*$"],
            disabledDatesText:"Date not available."
});

Answers


disabledDates config option accepts arrays of dates, so if you are saying you have the store handy, you can simply do something like:

var disabledDates = [];
store.each(function(record){
    disabledDates.push(record.get('putYourDateFieldNameHere'));
});
dateField = new Ext.form.DateField({
            format:"m/d/Y",
            disabledDates: disabledDates,
            disabledDatesText:"Date not available."
});

Try...

var disabledDates = [];
store.each(function(record){
    disabledDates.push(record.get('putYourDateFieldNameHere'));
});
dateField = new Ext.form.DateField({
            format:"m/d/Y",
            disabledDatesText:"Date not available."
});
dateField.setDisabledDates(disabledDates);

Need Your Help

Check if point lies between two sets of co-ordinates

javascript math coordinates point

I am creating a tower defence game and want to prevent the user placing towers on the path. The path is stored as an array of objects with properties x and y. I'll do a quick example to explain. Ma...

jQuery selector inside selector with NodeJS + Node.io

jquery node.js this selector node.io

I have a NodeJS app that is trying to use JQuery to scrape a webpage. Within the web page I am trying to scrape: