This project has moved and is read-only. For the latest updates, please go here.

How to check two filter columns with "OR" operator

May 3, 2011 at 12:34 PM

Hi Stephen,

I want to filter two columns at a time using "OR" condition. Means, any Executive is login, than he/she can able to see those tickets which are assigned to him/her "OR" the tickets which are created by him/her.

In current scenario I am able to check assigned ticket condition with using following highlighted code line color of choclate. If I add following highlighted red line, it will check owner column condition with AND operator not OR operator.

current scenario is as follows

select * from tickets where assignedto='' AND owner=''

I want to filter owner and assignedto column with or condition like,

select * from tickets where assignedto='' or owner=''

 //my tickets 



List<ListViewSortColumn> myticketsSortColumns = new List<ListViewSortColumn>();



List<ListViewFilterColumn> myticketsFilterColumns = new List<ListViewFilterColumn>();

myticketsSortColumns.Add(new ListViewSortColumn("LastUpdateDate", ColumnSortDirection.Descending));





if (SecurityManager.IsTicketSubmitter)



new ListViewFilterColumn("CurrentStatus", false, "closed"));


 myticketsFilterColumns.Add(new ListViewFilterColumn("Owner", true, user));



 else if (SecurityManager.IsExecutive)





 please reply for the same







myticketsFilterColumns.Add(new ListViewFilterColumn("AssignedTo", true, user));


new ListViewFilterColumn("Owner",true,user))); 


May 4, 2011 at 6:50 AM

That isn't a simple answer.

You can't do what you are looking for with the existing filter columns mechanisms. The filter columns and list preferences systems are based on very simple "AND" expressions. With "AND" expressions, the order of evaluation is not important and the system doesn't need to deal with expression grouping. This is the way the existing filter columns stuff if handled in TicketDesk currently.

Once you start trying to support "OR" expressions though, especially when used in conjunction with "AND" expressions, then you are in a whole different world; a world where you have to deal with the full complexity of expression operators, order of evaluation, and grouping scenarios.

You can probably modify TicketDesk for your needs, but how exactly depends on to what extent you want to support "OR" expressions. If it's a single list you want to hard-code this way, then it would be easier to simply hard-code in the additional OR expression in the controller or viewmodel behind the front-end view itself. That way, the existing user preferences system works as-is, and all you do is tack-on an "OR" expression afterwards.

But if you want to support OR expressions as a customizable, and variable, user preference; then at the very least you would need to modify the filter columns mechanisms to also store the kind of operator to use (AND/OR). Then, in the TicketRepository, you would need to deal with reading and using the stored conditional operator (currently the system just assumes "AND" is used)... but this is the part that can get tough, you may also need to handle the order of execution, and possibly grouping of expressions too.  Generally, when you start going down that road, what you have to do is model the preferences as "filter expression" objects, which is more of a heirachy of expression objects and their relationships with each other (where the current system is a simpler  loose collection "filter columns").