а

Filtering scheduler using combobox


#1

Hi I am trying to filter the scheduler based on a combo but can’t seem to figure it out.

I have filtering using a checkbox working, here is that code.
var course_Type_filters = {
1: true,
2: true,
3: true
};

var filter_inputs = document.getElementById(“filters_wrapper”).getElementsByTagName(“input”);

for (var i=0; i<filter_inputs.length; i++) {
var filter_input = filter_inputs[i];

// set initial input value based on filters settings
filter_input.checked = course_Type_filters[filter_input.name];

// attach event handler to update filters object and refresh view (so filters will be applied)
filter_input.onchange = function() {
	course_Type_filters[this.name] = !!this.checked;
	scheduler.updateView();
	updIcon(this);
}

}

// here we are using single function for all filters but we can have different logic for each view
scheduler.filter_month = scheduler.filter_day = scheduler.filter_week = function(id, event) {
// display event only if its type is set to true in filters obj
// or it was not defined yet - for newly created event
if (course_Type_filters[event.course_type] || event.course_type==scheduler.undefined) {
return true;
}

// default, do not display event
return false;

};

var course_types = [
{ key: “1”, label: “Waterfront” },
{ key: “2”, label: “Schoolhouse” },
{ key: “3”, label: “Special Training” }
];

==============================================================

I do not know exactly how to do it using the combo box. Combobox ID = combo_instructor

scheduler.filter_month = scheduler.filter_day = scheduler.filter_week = function(id, event) {

if (combo_instructor.key = event.instructor) {
	return true;
} else if (event.instructor==scheduler.undefined) {
	return true;
} else if (combo_instructor.key = 0) {
	return true;
}else {
	// default, do not display event
	return false;
}

};


#2

Hi,

You have almost the same code as in the sample https://docs.dhtmlx.com/scheduler/samples/09_api/09_filtering_events.html

It is difficult to understand what goes wrong while I can’t run your code. Create an example using the snippet system and send me the updated link to make it clear http://snippet.dhtmlx.com/8cb7f9024


#3

Thank you for the reply again Polina!

I am not sure how to code to filter by a combo selection. Any assistance would be greatly appreciated.

Snippet:
http://snippet.dhtmlx.com/3156ab906

Thanks!


#4

I forgot to add that I am supporting multiple Instructors on an event.

Thanks


#5

Sorry, I can’t help you using the demo because it looks like strange piece of code that doesn’t work at all and also the data in the snippet can’t be filtered with this code. If you need a help in development, you can contact our sales department.