Select Case e.Path
Case "test.htm"
Dim wb As New weui
wb.AddForm("","form1","tongji.htm")
With wb.AddInputGroup("form1","ipg1","销售统计")
.AddSelect("水平分组","水 平分组","产品|客户|雇员")
.AddSelect("垂直分组","垂直分组","产品|[客户]|雇员")
.AddSelect("统计列","统计列","数量|金额")
End With
With wb.AddInputGroup("form1","ipg2","动态赋值")
.AddInput("xm1","值1","text")
.AddInput("xm2","值2","text")
End With
With wb.AddButtonGroup("form1","btg1",True)
.Add("btn1", "统计", "button").Attribute= "onclick= 'tongji()'"
End With
wb.AppendHTML("<div id='p1' style='margin:0.5em'></div>") '插入一个div,用于显示服务器返回的 页面
wb.AppendHTML("<script src='./lib/ajaxform.js'></script>") '引入脚本文件
e.WriteString(wb.Build)
Case "tongji.htm"
Dim wb As New weui
If e.PostValues.ContainsKey("垂直分组") AndAlso e.PostValues.ContainsKey("水平分组") AndAlso e.PostValues.ContainsKey("统计列") Then
Dim b As New CrossTableBuilder("统计表1",DataTables("订单"))
b.HGroups.AddDef(e.PostValues("水平分组"))
b.VGroups.AddDef(e.PostValues("垂直分组"))
b.Totals.AddDef(e.PostValues("统计列"))
Dim dt As DataTable = b.Build(True)
With wb.AddTable("","Table1")
Dim lst As new List(of String)
For Each dc As DataCol In dt.DataCols
lst.Add(IIF(dc.Caption = "",dc.Name,dc.Caption))
Next
.head.AddRow(lst.ToArray)
For Each dr As DataRow In dt.DataRows
lst.Clear
For Each dc As DataCol In dt.DataCols
lst.Add(dr(dc.Name))
Next
.body.AddRow(lst.ToArray).Attribute= "onclick= 'setvalues()'"
Next
End With
Else
wb.InsertHTML("请按输入分组列和统计列!")
End If
e.WriteString(wb.Build)
End Select
ajaxform.js文件
function tongji(){
var result = submitAjaxForm('form1','',false);
document.getElementById("p1").innerHTML=result;
bindTable();
}
function bindTable() {
var eles = document.querySelectorAll(".fox_actionsheet");
for (var i = 0; i < eles.length; i++) {
eles[i].onclick = hide;
}
eles = document.getElementsByClassName("fox_table")
for (var i = 0; i < eles.length; i++) {
eles[i].onmousedown = tableMouseDown;
eles[i].rowSel = -1;
eles[i].colSel = -1;
if (eles[i].hasAttribute("data-pagenumber")) {
eles[i].pagenumber = eles[i].attributes["data-pagenumber"].value;
}
}
eles = document.getElementsByClassName("weui_mask_transition");
for (var i = 0; i < eles.length; i++) {
eles[i].addEventListener("transitionend", hideActionMask);
}
}
function setvalues(){
document.getElementById("xm1").value = table1.rows[table1.rowSel].cells[0].innerHTML;
document.getElementById("xm2").value = table1.rows[table1.rowSel].cells[1].innerHTML;
}