2

我们如何过滤从 REST 服务组件获取数据的 dojo 网格(extlib 组件)?我从 REST 服务组件正确地加载了视图中的数据。我在 xpage 上还有一个下拉列表,用户可以在其中选择一个值,该值是同一视图中某一列的 dbcolumn。我尝试将 REST 服务键值设置为 viewScope.filterCat01 (这是组合框的变量),并且我还尝试在按钮中设置过滤器(BY 是字段/列名称)但似乎没有过滤它。有任何想法吗?在我检查网格属性的按钮中,它确实有效,所以我知道网格对象是有效的 - 但过滤器似乎没有做任何事情。我也尝试过执行 grid._refresh() 以及在 REST 服务组件中设置键,但没有成功。

var filterValue = XSP.getElementById("#{id:comboBox2}").value;
var grid = dijit.byId("#{id:djxDataGrid1}");
grid.filter({ By: filterValue});
4

1 回答 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!

于 2012-04-25T15:41:56.213 回答