Kendo UI datepicker - month change event -
kendo ui datepicker - month change event
i searched here & on telerik forum don't have solution this.
here, want mark few dates month , did on open event below-
$.each(dates, function (index, date) { var reformatteddate = date.getfullyear() + '/' + date.getmonth() + '/' + date.getdate(); $('#datepickerid_dateview a.k-link[data-value="' + reformatteddate + '"]').parent().addclass("date-marking-class"); });
so, looping though dates , comparing data-value of datepicker calendar. on match found, applying class mark date.
it's working absolutely fine on datepicker open event whenever change month, it's not marking date @ all.
so want event trigger on month change, can execute 2 lines of code mark dates on new month.
you can use month
template of widget:
$("#date").kendodatepicker({ month: { content: $("#date-template").html() } });
it renders template each day if widget set month view. there can wrap day number span
desired class.
and template like:
# var month = data.date.getmonth() + 1; dates = months[month], found = false, result = data.value; if (dates && dates.length > 0) { (var = 0, len = dates.length; < len; i++) { var date = dates[i], datesplit = data.datestring.split("/"); if (date.getdate() == datesplit[2] && date.getmonth() == datesplit[1] && date.getfullyear() == datesplit[0]) { result = "<span class='date-marking-class'>" + data.value + "</span>"; break; } } } # #=result#
being months
object this:
// months contains array date objects(in case, days 10 , 20 each one) var months = { "1": [new date(2017, 0, 10), new date(2017, 0, 20)], "2": [new date(2017, 1, 10), new date(2017, 1, 20)], "3": [new date(2017, 2, 10), new date(2017, 2, 20)], "4": [new date(2017, 3, 10), new date(2017, 3, 20)], "5": [new date(2017, 4, 10), new date(2017, 4, 20)], "6": [new date(2017, 5, 10), new date(2017, 5, 20)], "7": [new date(2017, 6, 10), new date(2017, 6, 20)], "8": [new date(2017, 7, 10), new date(2017, 7, 20)], "9": [new date(2017, 8, 10), new date(2017, 8, 20)], "10": [new date(2017, 9, 10), new date(2017, 9, 20)], "11": [new date(2017, 10, 10), new date(2017, 10, 20)], "12": [new date(2017, 11, 10), new date(2017, 11, 20)] };
or anyway want - suggestion - since change line dates = months[month]
gives array of dates.
Comments
Post a Comment