从范例里面的看到的,此类方法不能使用setTable的办法插入数据
Code here
import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=1173;bottom=708)
winform.add(
listview={cls="listview";left=13;top=15;right=1159;bottom=688;edge=1;fullRow=1;gridLines=1;z=1}
)
/*}}*/
//表头
list1 = {"id","code","lx","jiage"}
for(i=1;#list1;1){
if(i = #list1){
winform.listview.insertColumn(list1[i],-1)
}
else {
winform.listview.insertColumn(list1[i],200)
}
}
//制作数组 不能是table 否者会报错
items = {}
for(i=1;100;1){
table.push(items,{i,i++"code"++i++"ddddd",i>50?"是":"否",i>50?i*(i-50):i*(i+2)})
}
//写入数据到listview
winform.listview.items = items
//为排序做准备 默认
winform.listview.itemData = items
winform.listview.itemSortColumn= 1
//排序函数
var reloadItemData = function(){
var sortColumn = winform.listview.itemSortColumn;
var itemData = winform.listview.itemData;
if(sortColumn<0){
var i = math.abs(sortColumn)
..table.sort(itemData,lambda(a) owner[i]>a[i])
}
else {
..table.sort(itemData,lambda(a) owner[sortColumn]<a[sortColumn])
}
winform.listview.replaceItems(itemData)
}
winform.listview.enableDoubleBuffering();
import win.ui.grid;
var grid = win.ui.grid(winform.listview);
/*
用户点击列头排序时会触发下面的事件,
column 为例号,desc 参数指定是否倒序,返回 true 允许当前列排序
*/
grid.onSortColumn = function(column,desc){
winform.listview.itemSortColumn = desc ?-column : column;
reloadItemData();
return true;
}
winform.show();
win.loopMessage();
这个速度挺快的