[JS] $("#scrollcontent").ejRangeNavigator({ load: "onLoad", rangeChanged: onchartloaded }); function onLoad(sender) { //load event triggered window.startDate = new Date(sender.data.model.selectedRangeSettings.start); window.endDate = new Date(sender.data.model.selectedRangeSettings.end); } function onchartloaded(sender) { //rangaChanged event triggered var rangeNavigator = $("#scrollcontent").data("ejRangeNavigator"); var start = sender.selectedRangeSettings.start; var end = sender.selectedRangeSettings.end; var startYear = start.getYear(); var endYear = end.getYear(); var diffYear = endYear - startYear; var startMonth = start.getMonth() + 1; var endMonth = end.getMonth() + 1; var diff; var startDate = start.getDate(); var endDate = end.getDate(); var diffDate = endDate - startDate; var month = start, date = 0; if (diffYear > 0) { var totMonth = diffYear * 12; endMonth = endMonth; startMonth = totMonth - startMonth; diff = startMonth + endMonth; } else diff = endMonth - startMonth; if (diff == 3) { if ((startDate == endDate) || ((startDate == (1 || 28 || 31)) && (endDate == (1 || 28 || 30)))) diff = diff; else if ((startDate != endDate) && ((startDate == (1 || 28 || 31)) && (endDate == (1 || 28 || 30)))) diff = diff + 1; } if (diff > 3) { sender.selectedRangeSettings.end = window.endDate; sender.selectedRangeSettings.start = window.startDate; rangeNavigator.redraw(); } window.startDate = sender.selectedRangeSettings.start; window.endDate = sender.selectedRangeSettings.end; } |