|
发表于 2017-8-16 17:44:31
|
显示全部楼层
全加载就会全渲染! 只能是延迟宣传才行!
一次性请求数据!但是不要一次性加载到data组件中!可以延迟加载到data组件中!
我这里有一点类似的代码!你可以参考
- //参数传递进去的是json ,返回也是json,加载数据需要获取的是json.rows
- Model.prototype.getChildJsonByParentID = function(parentID,dataJson){
- var json = $.extend(true,{},dataJson);
- var rows = json.rows;
- //如果当前行的子的行对象存在,
- if(rows){
- if(parentID){
- //递归寻找parentID的所有子
- for(var row in rows){
- //目前已经找到子对象数组,就不用再找了
- if(this.isFindChildRows){
- break;
- }
- //如果当前行的id就是就是父ID,就找到子的json对象返回。否则递归子去寻找
- if(rows[row].id.value == parentID){
- json = this.getChildJsonByParentID(null,rows[row]);
- this.isFindChildRows = true;//表示已经发现子对象数组了!不用再找了!
- break;
- }else{
- json = this.getChildJsonByParentID(parentID,rows[row]);
- }
- }
- }else{
- //删除当前的所有子
- for(var row in rows){
- delete rows[row].rows;
- }
- }
- }else{
- json = {};
- }
- return json;
- };
-
- Model.prototype.treeDataCustomRefresh = function(event){
- var me = this;
- this.isFindChildRows = false
- if(this.treeDataJson){
- var row = event.source.getCurrentRow();
- var json = me.getChildJsonByParentID(row.val('id'),this.treeDataJson);
- var rows = json.rows;
- if(rows){
- event.source.loadData(rows,true,row);
- }
- }else{
- biz.Request.sendHttpRequest({
- "contentType" : "application/json",
- "url" : require.toUrl("$UI/SA/OPM/dialogs/selectFunction/getFunctionData.j?mode=tree" + this.roots + this.files + this.identity + this.type),
- "callback" : function(xhr, ts) {
- if (biz.Request.isSuccess(xhr)) {
- me.treeDataJson = xhr.responseJSON;
- var json = me.getChildJsonByParentID(null,xhr.responseJSON);
- var rows = json.rows;
- if(rows){
- event.source.loadData(rows,true,row);
- }
- }
- }
- });
- }
-
-
-
- };
复制代码 |
|