custom query filter for event

Hello,

i just started using this tool and I find it very useful, powerful and flexible (Amazing job DHTMLX Team!).
Anyway, I have a question regarding creating a custom filter to retrieve certain events from the database.
How can I write a custom filter query for custom fields in the table so that I can see the events that I want.

For example:
I add a new field in the event table called ‘status’. The status field contains either ‘bad’ or ‘good’ value. Then I create a custom selectbox called ‘status’ in the html page (on top of the calendar box). When user select the status, it will update the calendar automatically with the new query.
Here is the code for the selectbox:

[code]

Good Bad [/code]

Can anyone guide me or point me to the right direction? I have gone through each of the post in this forum and found nothing for this kind of topic.

Thanks a lot for your help!

It possible to define client side filter method, something like

scheduler.filter_month = scheduler.filter_week = function(ev_id, event){ if(event.status != document.getElementById("status").value) return false; // event will be filtered (not rendered) //or return true; // event will be rendered } }

above assumes that you have “status” values in xml data feed.

Hi Stanislav,

It works like a charm, thank you very much!
Another question,
Is it possible to refresh the event page without reloading?
So, let’s say the user change the status filter from ‘bad’ to ‘good’,
Can we put a function on the onchange event on the selectbox?
Something like this:

<select id="status" name="status" onclick="updateCalendar()"></select>

Then, the updateCalendar() function will refresh the calendar through AJAX?

I know there is an auto update function: dp.setAutoUpdate(2000);
But it does not work in my code.

Really appreciate your help!

Hello,

I tried playing around with the javascript and I found the solution.

To anyone wondering how to auto refresh the calendar and take the current value of the status selectbox, here is the code:

selectbox code:

<select id="status" name="status"> <option value="good">Good</option> <option value="bad">Bad</option> </select>

declare a variable call status on the very top.

var status;

javascript code for scheduler filter:

scheduler.filter_month = scheduler.filter_week = function(ev_id, event){
		  if(event.CreatedById ==userId)
		  {

			  return true; // event will be rendered
		  }else{
			  return false; // event will be filtered (not rendered)
		  } 
		}

javascript code for auto update calendar:

var int=self.setInterval("updateCalendar()",3000);
	function updateCalendar()
	{
		status = document.getElementById("status").value;
		scheduler.load('01_basic_init_connector.php?uid='+scheduler.uid());
		
	}

Let me know if you guys encounter any issues, I would love to help and contribute to this great tool as well!

try
scheduler.update_view();

… it works for me !