Index: /trunk/web2/addons/job_monarch/js/jobgrid.js
===================================================================
--- /trunk/web2/addons/job_monarch/js/jobgrid.js	(revision 582)
+++ /trunk/web2/addons/job_monarch/js/jobgrid.js	(revision 583)
@@ -5,4 +5,5 @@
 var JobProxy;
 var SearchField;
+var filterButton;
 var myfilters = { };
 var myparams = { };
@@ -11,4 +12,15 @@
 
 var filterfields = [ "jid", "queue", "name", "owner" ];
+
+var filterMenu = new Ext.menu.Menu({
+    id: 'filterMenu',
+    items: [ new Ext.menu.Item({ text: 'Clear all', handler: clearFilters }) ]
+});
+
+var filterButton = new Ext.MenuButton({
+			id: 'filtermenuknop',
+			text: 'Filters',
+			menu: filterMenu
+		});
 
 Ext.namespace('Ext.ux');
@@ -56,4 +68,34 @@
 Ext.namespace( 'Ext' );
 
+function clearFilters()
+{
+	if( inMyArrayKeys( myfilters, 'host' ) )
+	{
+		delete myfilters['host'];
+		delete myparams['host'];
+	}
+	if( inMyArrayKeys( myfilters, 'jid' ) )
+	{
+		delete myfilters['jid'];
+		delete myparams['jid'];
+	}
+	if( inMyArrayKeys( myfilters, 'queue' ) )
+	{
+		delete myfilters['queue'];
+		delete myparams['queue'];
+	}
+	if( inMyArrayKeys( myfilters, 'owner' ) )
+	{
+		delete myfilters['owner'];
+		delete myparams['owner'];
+	}
+	if( inMyArrayKeys( myfilters, 'status' ) )
+	{
+		delete myfilters['status'];
+		delete myparams['status'];
+	}
+	reloadJobStore();
+}
+
 function makeArrayURL( somearr )
 {
@@ -94,4 +136,16 @@
   }
   return false;
+}
+
+function ArraySize( arr )
+{
+  count = 0;
+
+  for( arkey in arr )
+  {
+    count = count + 1;
+  }
+
+  return count;
 }
 
@@ -236,4 +290,42 @@
   ci_x = (window.innerWidth - ClusterImageWindow.getSize()['width'] - 20); 
   ClusterImageWindow.setPosition( ci_x, 10 );
+}
+
+function deselectFilterMenu( menuItem, event )
+{
+  filterValue = menuItem.text;
+
+  for( arkey in myfilters )
+  {
+    if( myfilters[arkey] == filterValue )
+    {
+      delete myfilters[arkey];
+      delete myparams[arkey];
+    }
+  }
+  reloadJobStore();
+}
+
+function makeFilterMenu()
+{
+  var filterMenu = new Ext.menu.Menu({
+      id: 'filterMenu',
+      items: [ new Ext.menu.Item({ text: 'Clear all', handler: clearFilters }) ]
+  });
+
+  if( ArraySize( myfilters ) > 0 )
+  {
+    filterMenu.addSeparator();
+  }
+
+  for( arkey in myfilters )
+  {
+    filterMenu.add( new Ext.menu.CheckItem({ text: myfilters[arkey], handler: deselectFilterMenu, checked: true }) );
+  }
+
+  if( filterButton )
+  {
+    filterButton.menu = filterMenu;
+  }
 }
 
@@ -431,33 +523,43 @@
 						delete myparams['query'];
 					}
-				}
-			}
-		},
-      		'load':
-		{
-      			scope: this,
-			fn: function()
-			{
-				if( SearchField )
-				{
-					search_value = SearchField.getEl().dom.value;
-
-					if( search_value != '' )
+					else
 					{
 						myfilters['query']	= search_value;
 					}
 
+					makeFilterMenu();
 					reloadClusterImage();
 
 					filter_str = myparams.c + ' Jobs Overview' + makeFilterString();
 					JobListingWindow.setTitle( filter_str );
-
-					if( search_value != '' )
-					{
-						delete myfilters['query'];
-					}
 				}
 			}
-		}
+		} //,
+      		//'load':
+		//{
+      		//	scope: this,
+		//	fn: function()
+		//	{
+		//		if( SearchField )
+		//		{
+		//			search_value = SearchField.getEl().dom.value;
+
+		//			if( search_value != '' )
+		//			{
+		//				myfilters['query']	= search_value;
+		//			}
+
+		//			reloadClusterImage();
+
+		//			filter_str = myparams.c + ' Jobs Overview' + makeFilterString();
+		//			JobListingWindow.setTitle( filter_str );
+
+		//			if( search_value != '' )
+		//			{
+		//				delete myfilters['query'];
+		//			}
+		//		}
+		//	}
+		//}
 	}
     });
@@ -698,4 +800,5 @@
 }
 
+
   JobListingEditorGrid =  new Ext.grid.EditorGridPanel({
       id: 'JobListingEditorGrid',
@@ -728,43 +831,5 @@
 				}
 			}),
-		new Ext.Button({
-				text: 'Clear filters',
-				tooltip: 'Clear all jobs filters',
-				iconCls: 'remove',
-				listeners: {
-					'click': {
-						scope: this,
-						fn: function()
-						{
-							if( inMyArrayKeys( myfilters, 'host' ) )
-							{
-								delete myfilters['host'];
-								delete myparams['host'];
-							}
-							if( inMyArrayKeys( myfilters, 'jid' ) )
-							{
-								delete myfilters['jid'];
-								delete myparams['jid'];
-							}
-							if( inMyArrayKeys( myfilters, 'queue' ) )
-							{
-								delete myfilters['queue'];
-								delete myparams['queue'];
-							}
-							if( inMyArrayKeys( myfilters, 'owner' ) )
-							{
-								delete myfilters['owner'];
-								delete myparams['owner'];
-							}
-							if( inMyArrayKeys( myfilters, 'status' ) )
-							{
-								delete myfilters['status'];
-								delete myparams['status'];
-							}
-							reloadJobStore();
-						}
-					}
-				}
-			}) ]
+		filterButton ]
     });
 
