Our pure JavaScript Scheduler component


Post by mikemcs »

What is the best way to populate a filter from a value in the URL:

Example using:
https://bryntum.com/products/schedulerpro/examples-scheduler/filtering/

1.jpg
1.jpg (87.29 KiB) Viewed 57 times
{
            type                 : 'textfield',
            ref                  : 'filterByName',
            icon                 : 'b-fa b-fa-filter',
            placeholder          : 'Find tasks by name',
            clearable            : true,
            width                : '15em',
            keyStrokeChangeDelay : 100,
            triggers             : {
                filter : {
                    align : 'start',
                    cls   : 'b-fa b-fa-filter'
                }
            },
            onChange({ value }) {
                value = value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');

            // Replace all previous filters and set a new filter
            scheduler.eventStore.filter({
                filters : event => event.name.match(new RegExp(value, 'i')),
                replace : true
            });
        }
    },	


Post by fabio.mazza »

There are many ways. It depends on many factors.

For this specific example, you could assign URL parameter value to the filter input, after the scheduler initialization.

const scheduler = new Scheduler({
	...
});

const
    searchParams = new URLSearchParams(window.location.search),
    filterValue = searchParams.get('filter_task');
	
scheduler.tbar.widgetMap.filterByName.value = filterValue;

Best regards,
Fabio


Post Reply