KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

DateTimePicker apply clientEvent not firing. #2512

Closed George opened this topic on on Dec 29, 2021 - 4 comments

George commented on Dec 29, 2021

Hi, I'm using the input DateTimePicker and I want to use the clientEvent apply but it doesn't seem to be running when selecting a new Date. This is how I have my DateTimePicker set up.

 <?php
                        DateTimePicker::create(
                            array(
                                "name"       => "single_date",
                                "format"     => "MMMM YYYY",
                                "attributes" => array(
                                    "class" => "form-control"
                                ),
                                "onReady"    => "function() {
                                    document.querySelector('#single_date > input').addEventListener('focus', function() { $('#single_date').data('datetimepicker').toggle(); }); 
                                    var d = new Date();
                                    d.setMonth(d.getMonth() - 1);
                                    $('#single_date').data('datetimepicker').options({
                                        maxDate: d,
                                        format: 'MMMM YYYY'
                                    })
                                }",
                                "clientEvents"=>array(
                                    "apply"=>"function(e, picker){
                                        console.log('applied')
                                    }", 
                                )
                            )
                        );
                        ?>

Any help is appreciated. Thank you, and happy holidays!

Sebastian Morales commented on Dec 30, 2021

Pls try "apply.daterangepicker" instead of "apply":

    "apply.daterangepicker"=>"function(e, picker){
        ...

Let us know the result. Tks,

George commented on Dec 30, 2021

apply.daterangepicker does not work unfortunately. Note I am using Datetimepicker not daterangepicker.

Sebastian Morales commented on Dec 30, 2021

Oh, sorry, I got the input wrong. In DateTimePicker case pls try the "change" client event:

    DateTimePicker::create(array(
        ...
        "clientEvents" => [
            "change" => "function(e) {
                console.log('DateTimePicker client event change', e);   
            }"
        ],
    ));
George commented on Jan 6, 2022

Thank you, this worked.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
bug
help needed

Inputs