.NET Core - Timepicker - Disble times

Hey,

I would like to disable some times in a timepicker like in the demo:

but unfortunately I can't find any information about it anywhere.

My goal is the following:


I select a date from the DatePicker and send an API call to my controller where I get back all the times which are reserved for that date and disable all these times in the timepicker.

I found a "disableItemCollection" property in the timepicker but I'm not sure it is what I need and how to use it.

Thank you in advance!

Ferenc


4 Replies 1 reply marked as answer

VJ Vinitha Jeyakumar Syncfusion Team June 13, 2022 10:04 AM UTC

Hi Ferenc,


Your requirement can be achieved by using the itemRender event of the Time picker control, where you can use the isDisabled arguments to disable the times in the popup list. 

Code snippet:
<div class=" control-section">
        <div class="timepicker-section">
            <div id="wrapper" class="timepicker-control">
                <div class="tabs-wrap">
                    <div class="wrap">
                        <ejs-timepicker id="timepicker" itemRender="itemRender" Item placeholder="Select a time"></ejs-timepicker>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
     function itemRender(args){
             if (args.text == '12:00 AM' || args.text == '7:00 AM') {
      args.isDisabled = true;
    }
        }
    </script>

Regards,
Vinitha

Marked as answer

FE Ferenc replied to Vinitha Jeyakumar June 13, 2022 10:29 AM UTC

Hello  Vinitha,


thank you this works properly, just another question. How can I call this function in another place? It waits for the args paramter. What should I give it?

itemRender(???) ?



Thank you, in advance!

Ferenc



FE Ferenc June 13, 2022 10:46 AM UTC

Hello  Vinitha,


in the meantime I think I figured it out how it works. If I click on the "clock" button in the Timepicker the function is called then. So I have to make my ajax call inside it and not call it from another function. Or at least I tink so... :)


Ferenc



PO Prince Oliver Syncfusion Team June 14, 2022 05:58 AM UTC

Hello Ferenc,


ItemRender is an event handler triggers when each popup item is rendered. This cannot be called from another function, but you can make calls to another function. Please let us know if you need any further assistance.


Regards,

Prince


Loader.
Up arrow icon