|
发表于 2017-11-30 18:45:58
|
显示全部楼层
本帖最后由 我是小菜鸡 于 2017-11-30 18:47 编辑
这是我以前做的一个自定义分页读取数据的功能,不知道能不能解决你的问题:
- // 统计数据加载
- Model.prototype.StaticticDataCustomRefresh = function(event) {
- var data = this.comp("StaticticData");
- //获取查询条件
- this.getSearchCondition();
- var params = {
- searchStr : searchStr,
- orderSql : orderSql,
- marketID : sessionStorage.getItem("marketID"),
- columns : justep.Baas.getDataColumns(data),
- limit : event.limit,
- offset : event.offset
- };
- // 从后台获得统计数据
- justep.Baas.sendRequest({
- "url" : "/hrzd/hrzd",
- "action" : "getDataStatistics",
- "async" : false,
- "params" : params,
- "success" : function(ret) {
- data.loadData(ret, event.options.append);
- }
- });
- };
复制代码- public static JSONObject getDataStatistics(JSONObject params, ActionContext context) throws SQLException, NamingException, java.sql.SQLException {
- String searchStr = params.getString("searchStr");
- String orderSql = params.getString("orderSql");
- String marketID = params.getString("marketID");
- Object column = params.get("columns");
- Integer limit = params.getInteger("limit");
- Integer offset = params.getInteger("offset");
- // 全部加载
- if (limit.equals(-1)) {
- limit = null;
- }
- Table table = null;
- Connection conn = context.getConnection(DATASOURCE_CRZD);
- String sql = "";
- try {
- sql = "select AddUserID,StockID,StockName,sum(StockCount) as StockCount from (select AddUserID, StockID, StockName, COUNT(*) as StockCount from V_Receive "
- + "where (IsDelete != 1 OR IsDelete IS NULL) " + searchStr + " AND MarketID = '" + marketID + "' group by AddUserID,StockID,StockName union all "
- + "select AddUserID, StockID, StockName, SUM(cast(StockCount as INT)) as StockCount from V_ReceiveSubNewS where (IsDelete != 1 OR IsDelete IS NULL) " + searchStr
- + " AND MarketID = '" + marketID + "' group by AddUserID,StockID,StockName)a group by AddUserID,StockID,StockName";
- table = DataUtils.queryData(conn, sql + orderSql, null, column, offset, limit);
- String countSql = "select count(*) from (" + sql + ")t";
- table.setTotal(Integer.parseInt(DataUtils.getValueBySQL(conn, countSql, null).toString()));
- return Transform.tableToJson(table);
- } finally {
- conn.close();
- }
- }
复制代码
|
-
|