自定义的action返回Table类型给data是默认是列表类型的,如果要返回树形的需要注意
1.java的Table中设置主键列
public static Table loadDataToTree() { String ksql = "select AP_SXSJ.fName,AP_SXSJ,AP_SXSJ.fParentID,AP_SXSJ.flevel ,AP_SXSJ.fKind from AP_SXSJ AP_SXSJ "; Table table = KSQL.select(ksql, null, "/appdemo/test/data", null); table.getProperties().put(Table.PROP_NAME_ROWID, "AP_SXSJ");//设置主键列 return table; }
2.在js调用action的时候需要设置父关系
Model.prototype.button10Click = function(event){ var tp = new biz.Request.TranslateParam(); tp.dataType = biz.Request.TranslateParam.DATATYPE_ROW_TREE; tp.setTreeOption('tree-parent-relation', "fParentID"); biz.Request.sendBizRequest({ "context" : this.getContext(), "action" : "loadDataToTreeAction", "translateParam" : tp, "callback" : function(callbackData) { if (callbackData.state) { console.log(callbackData.response); tree.refresh(); } } }); };
评一波