parmarmayur9090 / jquery-datepicker

Automatically exported from code.google.com/p/jquery-datepicker
0 stars 0 forks source link

How to pass database values to datepicker #155

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I want to know how i can pass date values from a database to the datepicker 
and have css highlight based on those values. Any idea how i get started. 

Original issue reported on code.google.com by leocr...@gmail.com on 3 Jan 2010 at 12:07

GoogleCodeExporter commented 8 years ago
You need to use a render callback like in this example:

http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerCustomCellR
ender.html

In the example I highlight weekends and make them unclickable. Instead of this 
logic
you could e.g. compare the date against the contents of a hidden input field 
which
your serverside language had filled with the dates as held in the database.

Original comment by kelvin.l...@gmail.com on 3 Jan 2010 at 10:00

GoogleCodeExporter commented 8 years ago
Thanks for your response. I am kind of a novice. Could you provide a simple 
example
of the above with say three dates. Thank you.

Original comment by leocr...@gmail.com on 4 Jan 2010 at 11:02

GoogleCodeExporter commented 8 years ago
I found a solution that works for me.  There is probably a more elegant 
solution out 
there and I am all ears...  But along with the isWeekend() method you could use 
the 
getDayOfYear() method.  Like so:

if (thisDate.isWeekend()) {
    $td.addClass('weekend');
    $td.addClass('disabled');
}
// 107th day of the year is April 19th...
if (thisDate.getDayOfYear() == 107)
{
    $td.addClass('weekend');
    $td.addClass('disabled');
}

That treats April 19th like a weekend, graying it out and disabling it from 
being 
selected.  

Original comment by whiti...@gmail.com on 12 Jan 2010 at 12:12

GoogleCodeExporter commented 8 years ago
You might also want to look at this example:

http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/renderCalendarBankHol
idays.html

Which shows how you can use an object containing references to certain dates 
along
with a renderCallback (renderCallback behaves the same for renderCalendar as it 
does
for datePicker).

Original comment by kelvin.l...@gmail.com on 13 Jan 2010 at 11:01

GoogleCodeExporter commented 8 years ago
Ah, thanks.  That is much more elegant and it works great.  I do have a 
question and 
do not feel like this is the proper place to post it, but since I have your 
attention and do not know where else to submit this question...  :)

I'm using a multi-month multi-date selector and am trying to POST it along with 
other form fields.  If I alert($('#multimonth').dpmmGetSelected()); then it 
shows 
all of the dates that have been selected (not in the proper format, but I'm 
trying 
to solve one thing at a time here).  So how do I assign those dates to the 
hidden 
form field so it will POST?

My code is attached.

Original comment by whiti...@gmail.com on 13 Jan 2010 at 6:27

Attachments:

GoogleCodeExporter commented 8 years ago
This example shows an approach to your problem:

http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerMultiMonth5
.html

Original comment by kelvin.l...@gmail.com on 25 Jan 2010 at 6:21

GoogleCodeExporter commented 8 years ago
Kelvin,  Thank you!  That is exactly what I needed!  You even included setting
multiple dates, which I was stuck on as well.  

Original comment by whiti...@gmail.com on 25 Jan 2010 at 4:30