|
1.自定义action,action中添加三个参数,limit(每页显示条数,Integer),offset(起始数,Integer),filterStr(过滤条件,String),然后生成procedure
2.点击代码,编写查询数据和分页的sql
- public static Table test(Integer limit, Integer offset, String filterStr) {
- // 设置where条件
- String whereStr = " where 1=1 ";
- if (!filterStr.isEmpty()) {
- whereStr += " and " + filterStr;
- }
- String sql = "SELECT o as fOrderID, o.* FROM DEMO_Orders o " + whereStr + " limit " + offset + ", " + limit;
- // 传入参数并执行SQL
- Table table = KSQL.select(sql, null, "/demo/common/data", null);//
- // table.getMetaData().setKeyColumn("fOrderID"); // 此方法也可以使用b
- table.getProperties().put("sys.rowid", "fOrderID");
- String cntSql = "SELECT count(o) as cn FROM DEMO_Orders o " + whereStr;
- Table cntTable = KSQL.select(cntSql, null, "/demo/common/data", null);
- int cnt = 0;
- if (cntTable.iterator().hasNext()) {
- cnt = cntTable.iterator().next().getInt(0);
- }
- table.getProperties().put("sys.count", cnt);
- System.out.println(cnt);
- return table;
- }
复制代码 3.在.w页面,放一个cData,在数据组件的接管刷新事件中,写传参和调用action代码
- Model.prototype.data1CustomRefresh = function(event) {
- var options = {};
- var param = new biz.Request.ActionParam();
- param.setInteger('limit', event.limit);
- param.setInteger('offset', event.offset);
- param.setString('filterStr', " o.fOrderDate < SQL.str_to_date('1998-01-08','%Y-%m-%d')");
- var process = "/demo/misc/process/CDataDemo/cDataDemoProcess";
- var activity = "mainActivity";
- options.contentType = 'application/json';
- options.dataType = "json";
- options.process = process;
- options.activity = activity;
- options.parameters = param;
- options.action = "testAction";
- options.callback = function(data) {
- if (data.state) {
- // 成功
- event.source.loadData(data.response);
- } else {
- // 失败
- Request.errorMessage(resultData, "执行失败!", null, null);
- }
- };
- var result = biz.Request.sendBizRequest(options);
- };
复制代码
|
评分
-
查看全部评分
|