Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Date Range Picker - Single Calendar for Range Selection

I'm using this date range picker component: http://www.daterangepicker.com/ and by default the widget shows two calendars. I would like to show only one calendar and be able to use the < > buttons to select next/previous months when selecting start and end dates i.e., be able to select a start date in January (showing only January) and then select an end date in March (showing only March), by clicking the > button. There is an option for singleDatePicker: true, but this disables the ability to select a range of dates.

like image 423
neridaj Avatar asked Jan 20 '17 18:01

neridaj


People also ask

What is JavaScript date range picker?

The JavaScript Date Range Picker provides an adaptive and responsive UI appearance for mobile devices. Control all the UI elements and behaviors of the Date Range Picker with a rich set of developer-friendly APIs to provide the best user experience.

How to create a daterangepicker with jQuery?

Features include selectable date range limit, translatable strings and date formats, single date picker mode, time picker, and preset time ranges. 1. Include the required jQuery library and moment.js on the web page. 2. Include the Daterangepicker plugin’s information. 3. Attach a primary date range picker to the input field. 4.

How to enable range selection in just one calendar?

You can use a hack to enable range selection in just one calendar: To insert just one calendar and works well you have to hidden the second calendar: $ (function () { $ ('input [name="daterange"]').daterangepicker ( { "autoapply": true }); $ ('.drp-calendar.right').hide (); $ ('.drp-calendar.left').addClass ('single'); });

What is DJs-Cropper and datetimerange picker?

js-cropper is a quick and easy way to add image cropping functionality to your web... Datetimerange Picker is a JavaScript component that is a date and time range picker, no build needed, no dependencies except for Moment.js, which is inspired by Dan Grossman’s boot data picker.


1 Answers

Code to remove second calendar for: http://www.daterangepicker.com Will be able to select a date range within one calendar.

/* REMOVE SECOND CALENDAR */

.daterangepicker .drp-calendar.right {
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
}

.daterangepicker .drp-calendar.right tbody {
    display: none !important;
}

.daterangepicker .drp-calendar.right thead > tr:nth-child(2) {
    display: none !important;
}

.daterangepicker .drp-calendar.right th.month {
    display: none !important;
}

.daterangepicker .drp-calendar.right .calendar-table {
    background: transparent !important;
}

.daterangepicker .daterangepicker.ltr .ranges, .daterangepicker.ltr .drp-calendar {
    float: none !important;
}

.daterangepicker .drp-calendar.right .daterangepicker_input {
    position: absolute !important;
}

/* REMOVE SECOND CALENDAR */
like image 198
cipriano Avatar answered Nov 14 '22 22:11

cipriano