框架为查询表格添加固定过滤条件有2种方式:
1)可以通过设置表格的filterItems属性或通过通用查询为查询表格设置过滤条件(适用于简单的查询条件过滤)。
2)后台拼接固定过滤条件的方法(适用于复杂的查询条件过滤)。
2.1样例配置如下图所示:
2.2关键说明:
点击表格,选中表格右边的”过滤条件”属性,添加相关的过滤条件 - - 样例图中的过滤条件是指“描述不是test333”的查询数据。
2.3显示效果:
3.1样例配置如下图所示:
3.2关键代码:
package com.kingdee.eas.custom;
import java.lang.Object;
import javax.servlet.http.HttpServletRequest;
import org.springframework.ui.ModelMap;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.webframework.dynamic.event.view.IWebListDataEventHandler;
import com.kingdee.bos.webframework.dynamic.event.view.WebListDataEvent;
import com.kingdee.bos.webframework.exception.WafException;
import com.kingdee.eas.framework.util.FilterUtility;
public class ListDataBeforeInitFilter extends Object implements IWebListDataEventHandler {
public void onRequest(WebListDataEvent event) throws WafException,
BOSException {
// TODO Auto-generated method stub
HttpServletRequest request = event.getReqeustContext().getHttpServletRequest();
ModelMap modelMap = event.getReqeustContext().get(ModelMap.class);
EntityViewInfo entityViewInfo = (EntityViewInfo)modelMap.get("DataGridEntityView");
if (entityViewInfo==null) {
entityViewInfo = new EntityViewInfo();
}
//可添加所需要的复杂过滤条件
String filterItems = "description != 'test11'";
try {
FilterInfo filterInfo = new FilterInfo(filterItems);
if (FilterUtility.hasFilterItem(entityViewInfo.getFilter())) {
entityViewInfo.getFilter().mergeFilter(filterInfo, "AND");
}else {
entityViewInfo.setFilter(new FilterInfo(filterItems));
}
} catch (Exception e) {
// TODO: handle exception
throw new WafException(e.toString());
}
modelMap.put("DataGridEntityView", entityViewInfo);
}
}
3.3显示效果:
1.配置页面
2.预览页面