21
Views
4
Comments
How to clear datepicker in table on dynamic checkbox check
Question

I am working on reactive application, there is requirement as create table with start date and end date as column name and date picker control in all rows of the table.  There is one more column as Select All available which is with checkbox in table header.

When select all checkbox is checked I want to fill all start date and end date with specific date (This is implemented and working fine) and if checkbox is unchecked then all date pickers should be clear out.

I tried using datepickerclear client action but unfortunately, I am unable to find Ids of start and enddate of datepicker block in widget tree because it is dynamic. I also tried by setting null date to current datepicker variable, but datepicker still showing value.

My question is how to clear all date pickers available in table?





You could use Javascript to collect the ID's based on a mutual class assigned to the date picker input widgets.


Let me know if you need more information 

It's kind of hacky but if you're operating inside a block you could just unload the block and then reload it to clear them all.

Probably not the most elegant method but would work quickly without any javascript or hard-coded/3rd party scripts.

If you do not want to use Javascript I would suggest you create a block with both start and end date as well as the row level checkbox you might need events to pass data to parent based on how you are using this data. Within the block you will have access to widgetid of your datepicker since there is only one instance here. You can call the block in your list.

You can then have an input parameter to the block based on value of select all to decide if you want to clear date or show it and based on the on the value of input in on parameters changed you can clear it.

Let me know if you need more details on this approach or the Javascript one.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.