Filtering

Hi all,

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.

I’ve tried the following:

[code]dhx.ready(function(){
dhx.ui.fullScreen();
dhx.ui({
view: “scheduler”,
id: “scheduler”
});
$$(“scheduler”).load(“personnel.xml”,“scheduler”);
$$(“scheduler”).filter("#cis#",“12345”);

[/code]

The “examples” I’ve been using are dhtmlx.com/docs/products/dht … obile.html

Thanks for the help.

Hi,

data filtering can be done only after xml with data are loaded:

$$(“scheduler”).load(“personnel.xml”,“scheduler”,doAfterLoading);

function doAfterLoading(){
$$(“scheduler”).filter("#cis#",“12345”);
}

Hi:

I also need to filter my events.

My feed is json not xml.

Also, I need to filter based on the type of view.

For example: In the day view I need to filter out timeless events, while in the list view I want to show them.

Any ideas?

Thanks Jim

Hi,

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]

Very nice, just what I was looking for… :smiley:

Hi:

Not sure what the problem is, but I’m still unable to log into the member site to open a ticket.

I’ve implemented filtering as described above and it works, but with one exception.

The filters are not taking effect on the first rendering of the view.

Here’s the flow of events:

  1. The scheduler is initialized

  2. $$(‘scheduler’).$$(‘day’).show();
    $$(‘scheduler’).$$(‘buttons’).setValue(‘day’);

  3. Get the data:
    $.ajax({ url: mobileApp.AppPath + "Calendar/CalendarData…,
    type: ‘GET’,
    dataType: ‘jason’,
    success: $.proxy(function (data) {
    this.filter();
    $$(“scheduler”).parse(data.responseText, “json”);

  4. Set the filter:
    filter: function () {
    var value = $$(“scheduler”).$$(“buttons”).getValue();
    if (value == “day”)
    this.filterDayActivity(); :arrow_right: (THIS EXECUTES)
    else
    if (value == “list”) {
    start_date_short_last = “”;
    this.filterListActivity();
    }

    }

  5. Parse the data.

  6. 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.

  1. Day view displays unfiltered data.

  2. Click the Day view button

  3. Event callback is fired
    eventID = $$(“scheduler”).$$(“buttons”).attachEvent(“onItemClick”, function (id, e) {
    me.filter();
    var value = this.getValue();
    if (value == “list”) {

    }

    }

  4. the filter is once again fired and set to day

  5. 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.

Any ideas on this one, it’s got me stumped…

Thanks again

Jim

Hi,

It would be more correct to filter scheduler after adding data:

success: $.proxy(function (data) {
$$(“scheduler”).parse(data.responseText, “json”);
this.filter();

da, I don’t know why I did that… :astonished: