当前位置 : 主页 > 编程语言 > java >

js中Ajax获取数据进行数据加载

来源:互联网 收集:自由互联 发布时间:2021-06-28
页面定义数据载体Table或者其他 事件类型 天数 处理开始时间 处理结束时间 处理人员 处理部门 说明 js中的Ajax代码 var ZBWFMID = ddlZBWFM.value; ajaxRequest("FillDataPBM.ashx", { action: "GetNewWorkFlowM
页面定义数据载体Table或者其他
 
                                                        
  
    
       
    事件类型  
    天数  
    处理开始时间  
    处理结束时间  
    处理人员  
    处理部门  
    说明  
    
  
 
js中的Ajax代码
var ZBWFMID = ddlZBWFM.value;
    ajaxRequest("FillDataPBM.ashx",
                { action: "GetNewWorkFlowModelList", ZBWFMID: ZBWFMID },
                "json",
                loadWorkModelListData);
Ajax应用的GetNewWorkFlowModelList方法获取页面需要的数据
public void GetNewWorkFlowModelList(HttpContext context)
        {
            HttpRequest Request = context.Request;
            HttpResponse Response = context.Response;

            if (Request["ZBWFMID"] != null)
            {
                IDDatabase da = new IDDatabase();
                DataSet ds = da.GetDataSetByStoredProcedure("ZBiddingDB.DBO.SP3_GetVNewZBWorkFlowModelList", new string[] { "@ZBWFMID" }, new DbType[] { DbType.String }, new object[] { Request["ZBWFMID"] });

                DataTable dt = new DataTable();
                if (ds != null && ds.Tables.Count > 0)
                {
                    dt = ds.Tables[0];
                }
                Response.Clear();
                Response.Write(JsonConvert.SerializeObject(dt));
                Response.End();
            }
        }
Ajax引用的loadWorkModelListData方法(js)给页面进行数据加载填充
var loadWorkModelListData = function (data, status) {
    clearTable(tbZBPLRemind);
    if (data.length > 0) {
        var cnt = data.length;
        for (var i = 0; i < cnt; i++) {
            var txtID1 = getUniqueKey("txt");
            var hidID1 = getUniqueKey("hid");
            var btnID1 = getUniqueKey("btn");

            var txtID2 = getUniqueKey("txt");

            var row = tbZBPLRemind.insertRow();
            var cell = row.insertCell(0);
            cell.align = "center";
            if (data[i].IsAllow == "N") {
                //不允许停用环节
                cell.innerHTML = getHiddenHtml("", data[i].ZBWFID);
                //cell.innerHTML = getCheckBoxHtml('', data[i].ZBWFID,{ "disabled": lvisAllow });
            }
            else {
                cell.innerHTML = getCheckBoxHtml('', data[i].ZBWFID);
            }

            cell = row.insertCell(1);
            cell.align = "left";
            //alert(data[i].ZBWFType);
            cell.innerHTML = data[i].ZBWFName + "";//IsAllow 是否允许禁用 2014-01-08 yanyl 改

            //var txtStart = getUniqueKey("txt");
            //var txtEnd = getUniqueKey("txt");
            //cell = row.insertCell(2);
            //cell.align = "center";
            //cell.innerHTML = getSelectDateHtml(txtStart, null, null, null, txtEnd);

            //cell = row.insertCell(3);
            //cell.align = "center";
            //cell.innerHTML = getSelectDateHtml(txtEnd);

            cell = row.insertCell(2);
            cell.align = "center";
            cell.innerHTML = getTextBoxHtml(txtID2, 2, null, "Updays(this)", data[i].DaysNumber);

            var txtStart = getUniqueKey("txt");
            var txtEnd = getUniqueKey("txt");
            cell = row.insertCell(3);
            cell.align = "center";
            if (data[i].ZBWFType == "14") {
                //选择完后跳至下一个焦点 
                //cell.innerHTML = getSelectDateHtml(txtStart, null, null, null, txtEnd, null, null, "NextData", "yyyy-MM-dd HH:mm");
                cell.innerHTML = getSelectDateHtml(txtStart, null, null, null, null, null, null, "KNextData", "yyyy-MM-dd HH:mm");//开标 
            } else if (data[i].ZBWFType == "12")
            {
                cell.innerHTML = getSelectDateHtml(txtStart, null, null, null, null, null, null, "FNextData");//发标
            } else
            {
                cell.innerHTML = getSelectDateHtml(txtStart, null, null, null, null, null, null, "FNextData");
            }

            cell = row.insertCell(4);
            cell.align = "center";
            if (data[i].ZBWFType == "14") {
                cell.innerHTML = getSelectDateHtml(txtEnd, null, null, null, null, null, null, null, "yyyy-MM-dd HH:mm");
            } else if (data[i].ZBWFType == "12") {
                cell.innerHTML = getSelectDateHtml(txtEnd, null, null, null, null, null, null, null);
            } else {
                cell.innerHTML = getSelectDateHtml(txtEnd);
            }


            cell = row.insertCell(5);
            cell.align = "left";
            cell.innerHTML = getSelectHtml(varTheme, txtID1, hidID1, btnID1, stringFormat("btnSelectStation_Click('{0}','{1}')", txtID1, hidID1));

            cell = row.insertCell(6);
            cell.innerHTML = getHiddenHtml("dept" + hidID1) + getTextBoxHtml("dept" + txtID1, 0, '', '', '', true);

            cell = row.insertCell(7);
            cell.align = "left";
            cell.innerHTML = getTextAreaHtml(txtID2) + getHiddenHtml('', data[i].ZBWFType) + getHiddenHtml('', data[i].ZBFCTID);

            setRowAttributes(row);
        }
    }
}
网友评论