以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]如何在父行显示子行数据呢? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=172835) |
-- 作者:c39lin -- 发布时间:2021/11/3 2:33:00 -- [求助]如何在父行显示子行数据呢? 比如父行的D列显示子行E列的第一个数据 或者F列出现频率最高的数据 |
-- 作者:有点蓝 -- 发布时间:2021/11/3 8:32:00 -- 参考:http://www.foxtable.com/webhelp/topics/1453.htm |
-- 作者:c39lin -- 发布时间:2021/11/7 3:35:00 -- 进行了几次尝试,都不行。 我是订单表里有自动生成订单编号,然后通过订单编号关联到订单明细表。 订单明细表里有通过商品链接关联商品表里的店铺名,订单明细表里的店铺名是表达式列。 那么我在订单表里如何自动显示出店铺名呢?
|
-- 作者:c39lin -- 发布时间:2021/11/7 3:38:00 -- ------订单表------ If e.DataCol.Name = "日期" Then If e.DataRow.IsNull("日期") Then e.DataRow("编号") = Nothing Else Dim bh As String = Format(e.DataRow("日期"),"yyyyMMdd") \'取得编号的8位前缀 If e.DataRow("编号").StartsWith(bh) = False \'如果编号的前8位不符 Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(编号)","日期 = #" & e.DataRow("日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) \'取得该天的最大编号 If max > "" Then \'如果存在最大编号 idx = CInt(max.Substring(9,3)) + 1 \'获得最大编号的后三位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("编号") = bh & "-" & Format(idx,"000") End If End If End If If e.DataCol.Name = "编号" Then \'如果内容发生变动的是编号列 If e.NewValue Is Nothing Then \'如果新值是空白,也就是品名列的内容为空 e.DataRow("店铺名") = Nothing \'那么清空此行单价列的内容 Else Dim dr As DataRow \'否则在产品表查找同名的产品行,将找到的行赋值给变量dr dr = DataTables("订单明细表").Find("[店铺名] = \'" & e.NewValue & "\'") If dr IsNot Nothing Then \'如果找到了同名的产品行,也就是dr不是Nothing e.DataRow("店铺名") = dr("店铺名") End If End If End If ----订单明细表---- If e.DataCol.Name = "店铺名" Dim Filter As String = "[编号] = \'" & e.DataRow("编号") & "\'" Dim drs As List(Of DataRow) = DataTables("订单表").Select(Filter) For Each dr As DataRow In drs dr("店铺名") = e.DataRow("店铺名") Next End If 试图这么操作,但是订单表里的店铺名列什么都不会显示。订单表里的店铺名列是数据列。
|
-- 作者:有点蓝 -- 发布时间:2021/11/7 20:22:00 -- ------订单表------ If e.DataCol.Name = "编号" Then \'如果内容发生变动的是编号列 If e.NewValue Is Nothing Then \'如果新值是空白,也就是品名列的内容为空 e.DataRow("店铺名") = Nothing \'那么清空此行单价列的内容 Else Dim dr As DataRow \'否则在产品表查找同名的产品行,将找到的行赋值给变量dr dr = DataTables("订单明细表").Find("[编号] = \'" & e.NewValue & "\'") If dr IsNot Nothing Then \'如果找到了同名的产品行,也就是dr不是Nothing e.DataRow("店铺名") = dr("店铺名") End If End If End If ----订单明细表---- If e.DataCol.Name = "店铺名" Dim Filter As String = "[编号] = \'" & e.DataRow("编号") & "\'" DataTables("订单表").DataCols("编号").RaiseDataColChanged(Filter ) End If |