以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  函数调用  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=147046)

--  作者:nxqtxwz
--  发布时间:2020/3/8 17:01:00
--  函数调用

下面的代码我看没什么错呀,为什么不对呢?

 

Dim dt As DataTable = Args(0)
Dim names As String() = Args(1).split(",")
Dim fields As String() = Args(2).split(",")
Dim arr As new jarray
For i As Integer = 0 To dt.DataRows.Count - 1
    arr.Add(new jobject)
    For j As Integer = 0 To names.Length - 1
        If Array.Indexof(names, "产品ID") <> -1 And names(j)="日期" Then   \'如果是订单表的日期
            arr(i)(names(j)) = Format(dt.DataRows(i)(fields(j)),"yyyy-MM-dd")
        Else
            arr(i)(names(j)) = dt.DataRows(i)(fields(j)).ToString
        End If
    Next
Next
Return arr


--  作者:有点蓝
--  发布时间:2020/3/8 22:37:00
--  
什么地方不对?这种代码没有数据比较没有办法判断问题,请上传实例测试
--  作者:nxqtxwz
--  发布时间:2020/3/9 9:27:00
--  

 

[此贴子已经被作者于2020/3/13 18:32:39编辑过]

--  作者:有点蓝
--  发布时间:2020/3/9 10:42:00
--  
哪个窗口?哪个功能?什么测试?
--  作者:有点蓝
--  发布时间:2020/3/9 10:53:00
--  
这样测试没有问题

Dim ar = Functions.Execute("tableJson",DataTables("订单"),"产品ID,客户ID,日期","产品ID,客户ID,日期")
Output.Show(ar.Tostring)

如果要考虑到列类型,可以参考一下这里的用法:http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=147034&page=3
--  作者:nxqtxwz
--  发布时间:2020/3/9 14:23:00
--  

出错提示是Args没有定义吧,但不知如何定义呢?

 

Dim dt As DataTable = Args(0)
Dim names As String() = Args(1).split(",")
Dim fields As String() = Args(2).split(",")
Dim arr As new jarray
For i As Integer = 0 To dt.DataRows.Count - 1
    arr.Add(new jobject)
    For j As Integer = 0 To names.Length - 1
        If Array.Indexof(names, "产品ID") <> -1 And names(j)="日期" Then   \'如果是订单表的日期
            arr(i)(names(j)) = Format(dt.DataRows(i)(fields(j)),"yyyy-MM-dd")
        Else
            arr(i)(names(j)) = dt.DataRows(i)(fields(j)).ToString
        End If
    Next
Next
Return arr


--  作者:有点蓝
--  发布时间:2020/3/9 14:55:00
--  
这个没有任何问题,应该是调用函数的时候没有传入参数,请参考5楼
--  作者:nxqtxwz
--  发布时间:2020/3/9 16:52:00
--  
以下是引用有点蓝在2020/3/9 14:55:00的发言:
这个没有任何问题,应该是调用函数的时候没有传入参数,请参考5楼

老师所说的5楼是哪个?我的页面上没有5楼,只有1楼啊?


--  作者:有点蓝
--  发布时间:2020/3/9 17:31:00
--  
本贴的5楼

Dim ar = Functions.Execute("tableJson",DataTables("订单"),"产品ID,客户ID,日期","产品ID,客户ID,日期")
Output.Show(ar.Tostring)