Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to preselect a range of dates?

The widget is configured to display 2 columns ( months ) :

function initialDateRangePicker(date_logiciel) { // date_logiciel is String representing date in format YYYY-MM-DD
    const picker = new easepick.create({
        element: "#closingDate",
        css: [
            "https://cdn.jsdelivr.net/npm/@easepick/bundle@1.2.1/dist/index.css"
        ],
        zIndex: 10,
        lang: "fr-FR",
        format: "DD/MM/YYYY",
        grid: 2,
        calendars: 2,
        plugins: [
            "RangePlugin",
            "KbdPlugin"
        ],
        RangePlugin: {
            delimiter: "  -  ",
        },
        setup(picker) {
            picker.on('select', (e) => {
                let debutObj = e.detail.start , finObj = e.detail.end;
                let debutStr = JSON.stringify(debutObj) , finStr = JSON.stringify(finObj);
                let debuts = debutStr.split("T") , fins = finStr.split("T");
                tableRemiseEnBanqueDatatables.getDatatable().destroy();
                tableRemiseEnBanqueDatatables.init(debuts[0], fins[0], JSON.parse('{ "id_liste": "#listeRemiseEnBanque", "icone": "/img/common/icones/bxs_bank.png", "titre": "Remise en banque" }'));
            });
        }
    });
    return picker;
}

How to make it at document ready to preselect date_logiciel to date_logiciel ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use the startDate and endDate options of the range plugin

...
RangePlugin: {
    delimiter: "  -  ",
    startDate: new Date(date_logiciel),
    endDate: new Date(date_logiciel),
},
...
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading