|
一个按钮,调用了一个自定义的Action事件,这个事件是建立了一个从表的数据的数据。//自定义Action
public static void createOP_DepCostCollectionCostitem(String fMasterID, String fDutyDepName, String fProjectID) { // 通过fProjectID,fDutyDepName查询并过滤项目成本科目记录
// 查询结果列:成本科目fID,费用名称fName,
String bselect = "select BD_CostItems.fID,BD_CostItems.fName from BD_CostItems BD_CostItems ";
String bfilter1 = "where BD_CostItems.fProjectID = '" + fProjectID + "' ";
String bfilter2 = "and BD_CostItems.fDutyDepName like '%" + fDutyDepName + "%'";
String bksql = bselect + bfilter1 + bfilter2;
Table costitemTable = KSQL.select(bksql, null, COSTITEM_MODLE, null);
// 新建明细表
// 成本科目迭代
Iterator<Row> rows = costitemTable.iterator();
String dselect = "select OP_DepCostCollectionDetail.* from OP_DepCostCollectionDetail OP_DepCostCollectionDetail ";
String dfilter1 = "where OP_DepCostCollectionDetail.fMasterID = '" + fMasterID + "'";
String dksql = dselect + dfilter1;
Table detailTable = KSQL.select(dksql, null, DEPCOST_MODLE, null);
detailTable.getMetaData().setKeyColumn("fID");
detailTable.getMetaData().setStoreByConcepts("OP_DepCostCollectionDetail");
while (rows.hasNext()) {
Row costRow = rows.next();
Row newRow = detailTable.appendRow(CommonUtils.createGUID());
newRow.setState(ModifyState.NEW);
newRow.setValue("version", 0);
newRow.setValue("fCostItemsID", costRow.getValue("fID"));
newRow.setValue("fMasterID", fMasterID);
newRow.setValue("fCharge", costRow.getValue("fName"));
}
detailTable.save(DEPCOST_MODLE);
}
//JS代码
Model.prototype.button8Click = function(event) {
var detailData = this.comp("detailData");
if (detailData.getCount() == 0) {
var params = new biz.Request.ActionParam();
params.setString("fMasterID", this.comp("mainData").getCurrentRow().val("fID"));
params.setString("fDutyDepName", this.comp("mainData").getCurrentRow().val("fDutyDepName"));
params.setString("fProjectID", this.comp("mainData").getCurrentRow().val("fProjectID"));
biz.Request.sendBizRequest({
"context" : this.getContext(),
"action" : "createOP_DepCostCollectionCostitemAction",
"parameters" : params,
"callback" : function(data) {
data.ignoreError = false;
if (data.state) {
justep.Util.hint("导入科目成功!");
detailData.refreshData();
} else {
throw new Error("导入科目失败!请联系管理员。");
}
}
});
} else {
alert("成本科目已导入!")
}
};
//因为在JS调用事件代码中加上了refreshData的方法,所以grid会马上展示
但是在之后,页面的主表data的保存按钮(我在页面中没有添加从表data的保存按钮)会异常,无论点击多少次都不会变成禁用状态
而且在关闭页面时会出现错误提示
Cannot read property 'jqGrid' of null
TypeError: Cannot read property 'jqGrid' of null at n.ViewComponent.extend.getGridParam (eval at <anonymous> (http://localhost:8080/x5/UI2/v_61d7f433b9e64478b2ba3ea577295142l_zh_CNs_desktopd_pc/system/core.min.js:1:0), <anonymous>:211:333718) at n.ViewComponent.extend.isGroupingField (eval at <anonymous> (http://localhost:8080/x5/UI2/v_61d7f433b9e64478b2ba3ea577295142l_zh_CNs_desktopd_pc/system/core.min.js:1:0), <anonymous>:211:330799) at eval (eval at <anonymous> (http://localhost:8080/x5/UI2/v_61d7f433b9e64478b2ba3ea577295142l_zh_CNs_desktopd_pc/system/core.min.js:1:0), <anonymous>:211:328991) at r.extend.fire (http://localhost:8080/x5/UI2/v_61d7f433b9e64478b2ba3ea577295142l_zh_CNs_desktopd_pc/system/core.min.js:59:240393) at r.extend.fireEvent (http://localhost:8080/x5/UI2/v_61d7f433b9e64478b2ba3ea577295142l_zh_CNs_desktopd_pc/system/core.min.js:59:241557) at justep.ModelComponent.extend._doValueChange (http://localhost:8080/x5/UI2/v_f6bf744ed7b54464ac516a4bc7096a96l_zh_CNs_desktopd_pc/system/common.min.js:7:32959) at null.callback (http://localhost:8080/x5/UI2/v_f6bf744ed7b54464ac516a4bc7096a96l_zh_CNs_desktopd_pc/system/common.min.js:7:31969) at Object.f.notifySubscribers (http://localhost:8080/x5/UI2/v_61d7f433b9e64478b2ba3ea577295142l_zh_CNs_desktopd_pc/system/core.min.js:59:136660) at Object.u.utils.extend.valueHasMutated (http://localhost:8080/x5/UI2/v_61d7f433b9e64478b2ba3ea577295142l_zh_CNs_desktopd_pc/system/core.min.js:59:139651) at Object.u.utils.extend.set (http://localhost:8080/x5/UI2/v_61d7f433b9e64478b2ba3ea577295142l_zh_CNs_desktopd_pc/system/core.min.js:59:139466)
|
|