I’ve been trying to create a simple filter, and am able to create a filter using the touchui.js, but cannot figure out how to use it for the dhtmlxscheduler_mobile.js. Ideally, I create a filter list of possible users from a xml file (which I can do using the touchui.js), then when they click “Filter” which redirects them to the calendar filtered by the user they select.
For example: In the day view I need to filter out timeless events, while in the list view I want to show them.
[code]$$(“scheduler”).$$(“buttons”).attachEvent(“onItemClick”,function(){
var value = this.getValue();
if(value==“day”)
filterTimeless();
else
resetFilter();
})
function filterTimeless(){
$$(“scheduler”).filter(function(event){
var startTime = (event.start_date.valueOf()!=dhx.Date.datePart(event.start_date).valueOf())
var endTime = (evevnt.end_date.valueOf()!=dhx.Date.datePart(event.end_date).valueOf())
return startTime&&endTime;
})
}
function resetFilter(){
$$(“scheduler”).filter(function(){return true})
}[/code]
Get the data:
$.ajax({ url: mobileApp.AppPath + "Calendar/CalendarData…,
type: ‘GET’,
dataType: ‘jason’,
success: $.proxy(function (data) {
this.filter();
$$(“scheduler”).parse(data.responseText, “json”);
Set the filter:
filter: function () {
var value = $$(“scheduler”).$$(“buttons”).getValue();
if (value == “day”)
this.filterDayActivity(); (THIS EXECUTES)
else
if (value == “list”) {
start_date_short_last = “”;
this.filterListActivity();
}
…
}
Parse the data.
template callback is invoked:
scheduler.templates.day_event = $.proxy(function(obj, type)
{
return formatDayActivity(obj, type); (THIS SIMPLY FORMATS THE DATA AND RETURNS
}, this);
The problem is that the call back returns all the data, not filtered for the day view.
Day view displays unfiltered data.
Click the Day view button
Event callback is fired
eventID = $$(“scheduler”).$$(“buttons”).attachEvent(“onItemClick”, function (id, e) {
me.filter();
var value = this.getValue();
if (value == “list”) {
…
}
…
}
the filter is once again fired and set to day
the day view now returns correctly filtered results.
This same pattern holds true for the Month and list views…
I’ve tried moving things around, but with no success.