以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]批量复制批注 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=121799) |
-- 作者:积水成渊 -- 发布时间:2018/7/13 10:33:00 -- [求助]批量复制批注 我要做一个批量复制批注的功能,就跟Ctrl+D的功能一样,存放批注的方式采用了Json 字段为SYS_Note,下面是我写的代码,基本的功能已经实现,麻烦老师们帮看再看看,看看哪些地方写的不好,如何进行改善 Dim t As Table = CurrentTable If t.Current Is Nothing Then Return False If t.TopPosition < 0 Then Return False \'如果选定区域不包括数据行 Dim json As String = t.Current("SYS_Note") Dim jo As JObject = JObject.Parse(json) \'messagebox.show(jo(CurrentTable.Cols(CurrentTable.ColSel).Name)) If t.Current.IsNull("SYS_Note") = True Or t.Current("SYS_Note") = Nothing Then Return False Else \'messagebox.show(json) Dim it As Win.Data.ITable = SYS.Tables(t.Name) For i As Integer = it.TopRow To it.BottomRow Dim r As Win.Data.IRow = it.Rows(i) If r.Visible = False Then Continue For If r.Isnull("SYS_Note") = True Or r("SYS_Note") = Nothing Then Dim jo1 As New JObject jo1(CurrentTable.Cols(CurrentTable.ColSel).Name) = jo(CurrentTable.Cols(CurrentTable.ColSel).Name) \'Output.Show(jo1.ToString) r("SYS_Note") = jo1.ToString r.Save Dim fdr As DataRow = t.DataTable.Find("_Identify = " & r("_Identify")) If fdr IsNot Nothing Then fdr.Load End If \'r.load Else If r("SYS_Note").Contains(CurrentTable.Cols(CurrentTable.ColSel).Name) = True Then \'接下来需要处理的地方,如何向json中修改当前列名对应的值,先生成json,再将json赋值给r("SYS_Note") Dim json1 As String = r("SYS_Note") Dim jo2 As JObject = JObject.Parse(json1) jo2(CurrentTable.Cols(CurrentTable.ColSel).Name) = jo(CurrentTable.Cols(CurrentTable.ColSel).Name) r("SYS_Note") = jo2.Tostring r.Save Dim fdr As DataRow = t.DataTable.Find("_Identify = " & r("_Identify")) If fdr IsNot Nothing Then fdr.Load End If \'r.load \'output.show(r("SYS_Note")) \'判断遍历的列名在json中是否存在,如果存在直接替换,如何不存在,新建json Else \'待加代码 \'messagebox.show("不存在") Dim json1 As String = r("SYS_Note") Dim jo2 As JObject = JObject.Parse(json1) jo2(CurrentTable.Cols(CurrentTable.ColSel).Name) = New JObject jo2(CurrentTable.Cols(CurrentTable.ColSel).Name) = jo(CurrentTable.Cols(CurrentTable.ColSel).Name) r("SYS_Note") = jo2.Tostring r.Save Dim fdr As DataRow = t.DataTable.Find("_Identify = " & r("_Identify")) If fdr IsNot Nothing Then fdr.Load End If \'r.load \'output.show(r("SYS_Note")) End If End If Next End If |
-- 作者:积水成渊 -- 发布时间:2018/7/13 10:36:00 -- 而且我发现一个问题,就是我加载行的时候失效了,明明已经将某列的批注改了,但是界面上没有呈现效果出来,需要加载整张表才有效,这个是怎么回事 |
-- 作者:有点甜 -- 发布时间:2018/7/13 10:41:00 -- 1、没看懂你的逻辑;
2、请做一个项目发上来测试。 |