1. 程式人生 > 其它 >點選按鈕,子表填充關聯表單的所有資料

點選按鈕,子表填充關聯表單的所有資料


前端程式碼
// 提交後事件 AfterSubmit: function( action, responseValue ) {
//
addStage 按鈕控制元件




if( action == "addStage" ) { $.SmartForm.PostForm( "getStage", { isStage: "1" }, function( data ) { //alert( JSON.stringify( data.ReturnData[ "dataList" ] ) ); var data1 = data.ReturnData[ "dataList" ]; // debugger if( data1 != null
) { that.addStage.SetVisible( false ); var details = that.D000772F06847ec1bd334b93a905fdc3049187e6; details.ClearRows(); var result = data1; if( result != null || result.length > 0 ) { for( i = 0;i < result.length;i++ ) { var controlManager = that.D000772F06847ec1bd334b93a905fdc3049187e6;//獲取子表控制元件物件 var subObjectId = $.IGuid(); //
建立行ID debugger controlManager.AddRow( subObjectId, { "D000772F06847ec1bd334b93a905fdc3049187e6.workDetail": result[ i ], }) } } } }, function( data ) { $.IShowWarn( "異常,請聯絡管理員" ); }, false ); }
 
//後端程式碼,連線前端程式碼
protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response) {
if(actionName == "getStage") { response.ReturnData = new Dictionary<string, object>(); String isStage = this.Request["isStage"] + String.Empty; response.ReturnData.Add("dataList", selectSon(isStage)); } base.OnSubmit(actionName, postValue, response); } public List < string > selectSon(String isStage) { List < string > objectIdList = new List<string>(); if(isStage == "1") { //查詢專案階段子表 string sql = "SELECT * FROM I_D000772Fkmjm7ijwd1ilmhr6yst8ige86 ORDER BY sort ASC"; // string sql = "select * from I_D000772Fkmjm7ijwd1ilmhr6yst8ige86 ORDER BY sort DESC"; System.Data.DataTable dtAccount = this.Request.Engine.Query.QueryTable(sql, null); if(dtAccount != null || dtAccount.Rows.Count > 0) { for(int i = 0;i < dtAccount.Rows.Count; i++) { objectIdList.Add(dtAccount.Rows[i]["objectId"] + string.Empty); } } } return objectIdList; }