2

How do we filter the dojo grid (extlib component) that gets its data from the REST service component? I have the grid loaded with data from the view correctly from the REST service component. I also have on the xpage a dropdown where users can select a value that's a dbcolumn of one of the columns in the same view. I've tried setting the REST service keys value to viewScope.filterCat01 (which is the variable for the combo box), and I've also tried setting the filter in a button (BY is the field/column name) but nothing seems to filter it. Any ideas? In the button when I check grid properties, it does work, so I know the grid object is valid - but the filter just doesn't seem to be doing anything. I've also tried doing a grid._refresh() as well as setting the Keys in the REST service component with no luck. Is there a special way to trigger the filter?

var filterValue = XSP.getElementById("#{id:comboBox2}").value;
var grid = dijit.byId("#{id:djxDataGrid1}");
grid.filter({ By: filterValue});
2
  • 1
    Can you show the whole XPage? You need to make sure you refresh the Rest Service when you alter the combobox.
    – stwissel
    Commented Apr 5, 2012 at 8:11
  • I finally just set the REST service search property to viewScope.<somefield> and then did a refresh of the REST service object rather than trying to manipulate the grid directly clientside. I'm still not sure why it doesn't work client side, but this solution works for now.
    – Anil
    Commented Apr 7, 2012 at 0:12

1 Answer 1

1

This is definitely one of those things that you need to piece together a thousand cryptic clues to work it out (Domino - never!). Anyway, I had to work this one out last year. Here's an example 'search' button:

var searchText = dojo.byId('#{id:searchText}').value.replace(/"/g, '|"');
if (searchText) {
  var ftSearchText = '[Title] CONTAINS "' + searchText + '" OR [Description] CONTAINS "' + searchText + '" OR [URL] CONTAINS "' + searchText + '"';
  dijit.byId('#{id:grid}').filter('?search=(' + ftSearchText + ')', false);
} else {
  dojo.byId('#{id:reset}').click();
}

As you can see, it's doing an ft search when a filter is applied. The key is to put "?search=" on to the beginning of the filter string.

and here's the 'reset' button example:

dojo.byId('#{id:searchText}').value="";
var grid = dijit.byId('#{id:grid}');
grid.filter("",true);
grid.store.close();
grid._refresh();

This was developed with 8.5.2. There might be some cleaner ways to do things in 8.5.3 with dojo 1.6.1.

Enjoy!

Not the answer you're looking for? Browse other questions tagged or ask your own question.