虚表 —— 实现公式的方法

光庆 23天前 357

import win.ui;
import godking.vlistEx;
/*DSG{{*/
mainForm = win.form(text="vlistEx - table adapter";right=849;bottom=578;border="thin")
mainForm.add(
button2={cls="button";text="过滤";left=280;top=520;right=392;bottom=570;z=2};
button3={cls="button";text="取消过滤";left=456;top=520;right=568;bottom=570;z=3};
vlist={cls="vlistEx";left=8;top=8;right=838;bottom=513;db=1;dl=1;dr=1;dt=1;edge=1;transparent=1;z=1}
)
/*}}*/

var t = {fields={"数1","数2","和"}};
for(i=1;11;1){
    table.push(t,{});
}
t[11]["数1"]="合计";
mainForm.vlist.setTable(t,,100,1);
mainForm.vlist.setRowColor(mainForm.vlist.count,0x000000/*文本颜色*/,0xDDDDFF/*背景颜色*/);
mainForm.vlist.onEditBegin = function(row/*行*/,col/*列*/){
	return col!==3 and row!==11; 
}
mainForm.vlist.editOnClick = true;
var sum = function(row){
    var a = tonumber(mainForm.vlist.getCellText(row,1):"0"):0;
    var b = tonumber(mainForm.vlist.getCellText(row,2):"0"):0;
    mainForm.vlist.setCellText(row,3,a+b);
    var s = 0;
    for(i=1;mainForm.vlist.count-1;1){
    	s += tonumber(mainForm.vlist.getCellText(i,3):"0"):0;
    }
	mainForm.vlist.setCellText(mainForm.vlist.count,3,s);
}
mainForm.vlist.onEditEnd = function(row/*行*/,col/*列*/,text/*内容*/,endType/*结束类型*/){
    return true,sum,row;
}
mainForm.show();
win.loopMessage();


最新回复 (1)
  • redchina 13天前
    0 引用 2

    拷贝代码试了不能计算,问题不知出在哪,后下载了最新的godking.vlistEx后正常

返回