普通data上有limit可以设置页记录数,等于-1时不执行分页一次取全部数据,运行时谨慎修改,会影响数据导航条分页取数据状态
自己通过调用action给data加载数据的时候要通过limit和offset的值去控制分页,具体如下
action中对应的java代码的实现:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public static Table loadMain(Integer limit,Integer offset){ //根据传的limit和offset控制查的数据记录数 String ksql = "select zsj,zsj.fName,zsj.fCode from AP_ZHJ zsj limit " +Integer.toString(offset)+ "," +Integer.toString(limit); Table table = KSQL.select(ksql, null , "/appdemo/test/data" , null ); //设置主键 table.getProperties().put(Table.PROP_NAME_ROWID, "zsj" ); //设置总记录数 , 计算分页 Table tCount = KSQL.select( "select count(a) as cnt from AP_ZHJ a" , null , "/appdemo/test/data" , null ); BigDecimal num = tCount.iterator().next().getDecimal( "cnt" ); table.getProperties().put(Table.PROP_DB_COUNT, num); return table; } |
在data的onCustomRefresh事件中调用action加载数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | Model.prototype.data1CustomRefresh = function (event){ var data1 = this .comp( "data1" ); //获取data var grid1 = this .comp( "grid1" ); //获取展现数据的grid组件 //勾选action参数,给limit和offset参数传参 var param = new biz.Request.ActionParam(); var limit = data1.limit; //获取data的limit值 var offset = data1.getOffset(); //获取data当前的offset值 param.setInteger( "limit" , limit); param.setInteger( "offset" , offset); biz.Request.sendBizRequest({ "context" : this .getContext(), "action" : "loadMainAction" , "parameters" : param, "callback" : function (callbackData) { callbackData.ignoreError = false ; if (callbackData.state) { data1.loadData(callbackData.response, false ); //把返回的数据给data grid1.refresh(); //刺激grid显示数据 } } }); }; |
data的定义注意limit的设置:
1 2 3 4 5 6 | < div component = "$UI/system/components/justep/data/data" autoLoad = "true" xid = "data1" idColumn = "fID" limit = "5" onCustomRefresh = "data1CustomRefresh" > < column label = "主键" name = "fID" type = "String" xid = "xid1" /> < column label = "名称" name = "fName" type = "String" xid = "xid2" /> < column label = "编码" name = "fCode" type = "String" xid = "xid3" /> </ div > |
评一波