以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- fill动态加载的表,增加的_Sortkey 不能排序吗? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=89429)
|
-- 作者:fubblyc
-- 发布时间:2016/8/22 0:14:00
-- fill动态加载的表,增加的_Sortkey 不能排序吗?
fill动态加载的表,增加的_Sortkey 不能排序吗?
此主题相关图片如下:微信截图_20160822001007.png

另外,为什么生成的_Sortkey值都是0
此主题相关图片如下:微信截图_20160822001309.png

代码:
Tables(e.Form.Name & "_table1").fill(sql3,"vip",True)
If Tables(e.Form.Name & "_table1").Cols.Contains("_SortKey") = False Then DataTables(e.Form.Name & "_table1").DataCols.Add("_SortKey", Gettype(Double)) End If
With e.Form.Controls("table1").Table For i As Double = 0 To .Rows.Count - 1 .Rows(i)("_SortKey") = i+1 Next End With
[此贴子已经被作者于2016/8/22 0:14:50编辑过]
|
-- 作者:Hyphen
-- 发布时间:2016/8/22 9:17:00
--
For i As Double = 0 To .Rows.Count - 1 .Rows(i)).DataRow.baserow("_SortKey") = i+1 Next
|
-- 作者:大红袍
-- 发布时间:2016/8/22 9:34:00
--
加一句
e.Form.Controls("table1").Table.Sort = "_Sortkey"
e.Form.Controls("table1").Table.Sort = ""
|
-- 作者:fubblyc
-- 发布时间:2016/8/22 16:35:00
--
红袍老师,你的这个代码 加在哪里?
我加在
For i As Double = 0 To .Rows.Count - 1 .Rows(i)).DataRow.baserow("_SortKey") = i+1 Next
后面。
不加的话,改变SortKey值 没有移动行,加了就会出现错误:
此主题相关图片如下:微信截图_20160822162640.png

[此贴子已经被作者于2016/8/22 16:35:09编辑过]
|
-- 作者:大红袍
-- 发布时间:2016/8/22 16:48:00
--
Dim t As Table\' = e.Form.Controls("table1").Table
t.DataTable.DataCols.Add("_Sortkey", Gettype(Double))
For i As Double = 0 To t.Rows.Count - 1 t.Rows(i).DataRow.baserow("_SortKey") = i+1 Next
t.Sort = "_Sortkey" t.Sort = ""
|
-- 作者:fubblyc
-- 发布时间:2016/8/22 16:58:00
--
红袍老师,还是一样。
\'If Tables(e.Form.Name & "_table1").Cols.Contains("_SortKey") = False Then \'DataTables(e.Form.Name & "_table1").DataCols.Add("_SortKey", Gettype(Double)) \'End If \' \'With e.Form.Controls("table1").Table \'For i As Double = 0 To .Rows.Count - 1 \'.Rows(i).DataRow.baserow("_SortKey") = i+1 \'Next \'End With \' \'e.Form.Controls("table1").Table.Sort = "_SortKey" \'e.Form.Controls("table1").Table.Sort = ""
上面的是我之前写的
下面的是你给的代码:
Dim t As Table = e.Form.Controls("table1").Table
t.DataTable.DataCols.Add("_Sortkey", Gettype(Double))
For i As Double = 0 To t.Rows.Count - 1 t.Rows(i).DataRow.baserow("_SortKey") = i+1 Next
t.Sort = "_Sortkey" t.Sort = ""
|
-- 作者:fubblyc
-- 发布时间:2016/8/22 17:03:00
--
不加
t.Sort = "_Sortkey" t.Sort = ""
测试是有 _Sortkey 列
此主题相关图片如下:微信截图_20160822170238.png

|
-- 作者:大红袍
-- 发布时间:2016/8/22 17:04:00
--
改变_Sorktey后,执行
t.Sort = "_Sortkey" t.Sort = ""
|
-- 作者:fubblyc
-- 发布时间:2016/8/22 17:32:00
--
我这样做:
此主题相关图片如下:after.png

排序后 结果是这样
此主题相关图片如下:排序后.gif

[此贴子已经被作者于2016/8/22 17:33:19编辑过]
|
-- 作者:大红袍
-- 发布时间:2016/8/22 19:13:00
--
试试
If Tables(e.Form.Name & "_table1").DataTable.DataCols.Contains("_SortKey") = False Then DataTables(e.Form.Name & "_table1").DataCols.Add("_SortKey", Gettype(Double)) End If
With e.Form.Controls("table1").Table For i As Double = 0 To .Rows.Count - 1 .Rows(i)("_SortKey") = i+1 Next End With
e.Form.Controls("table1").Table.Sort = "_SortKey" e.Form.Controls("table1").Table.Sort = ""
|