![]() |
1.实时查询、分页、以及后端排序的完整例子; 2.这是单个Treelist组件,同时开启了topBar和bottomBar,其中树列表的XML、查询条件 和 分页器的freeform XML直接采用了以前的例子; |
![]() |
|
1.XML描述文件、数据库都采用了前面的例子,这是全部的资源: Treelist的XML描述文件、 topBar的XML描述文件、 freeform分页器的XML描述文件、后端的access数据库文件(access.mdb)、 后端的C#源码. 2.在OnReady( )中开启了tBar和bBar:
function OnReady(id)
{
AF.func("Build", "treelist/t1.xml");
AF.func("OpenFreeformBar","treelist/query2.xml \r\n tBar"); //打开topBar
AF.func("OpenFreeformBar","treelist/pager2.xml \r\n bBar"); //打开bottomBar
AF.func("SetProp", "IsRemoteSort \r\n true"); //指定服务器端排序
//绑定分页器=======
//取得Treelist句柄
var h = AF.func("GetHandle", "");
//调用bottomBar的freeform的扩展函数:绑定Treelist
AF.func("bBar.BindPager", h + "\r\n ID0");
//设置分页器的dataURL (将自动加载Treelist数据)
AF.func("bBar.SetObjectProp", "ID0\r\n dataURL \r\n" + genUrl() + "\r\n mode=asynch"); //让Treelist异步加载数据
}
3.在OnEvent( )事件的源码:
function OnEvent(id, Event, p1, p2, p3, p4)
{
//按钮事件============
if(Event=="ButtonClicked") {
//bottomBar中左侧的按钮事件
if(p1=="IDRefresh") {
AF.func("refresh", "");
return;
}
if(p1=="IDPrint") {
AF.func("printPreview", "");
return;
}
//工具条功能
if(p1 == "close1" || p1=="close2") //关闭查询
AF.func("TBar.SetObjectProp", "layout1,layout2,mirror \r\n visible \r\n 0");
else if(p1 == "btn1") { //开启查询条件1
AF.func("TBar.SetObjectProp", "layout2 \r\n visible \r\n 0");
AF.func("TBar.SetObjectProp", "mirror, layout1 \r\n visible \r\n 1");
}
else if(p1 == "btn2") { //开启查询条件2
AF.func("TBar.SetObjectProp", "layout1 \r\n visible \r\n 0");
AF.func("TBar.SetObjectProp", "mirror, layout2 \r\n visible \r\n 1");
}
else if(p1=="ok1" || p1=="ok2") { //查询动作
if(p1=="ok1") { //取得日期条件
od1 = AF.func("TBar.GetValue", "orderDate1");
od2 = AF.func("TBar.GetValue", "orderDate2");
rd1 = AF.func("TBar.GetValue", "requireDate1");
rd2 = AF.func("TBar.GetValue", "requireDate2");
f1 = f2 = "";
}
else { //取得货重条件
f1 = AF.func("TBar.GetValue", "freight1");
f2 = AF.func("TBar.GetValue", "freight2");
od1 = od2 = rd1 = rd2 = "";
}
AF.func("BBar.SetObjectProp", "ID0\r\ndataURL\r\n" + genUrl() + "\r\n mode=Asynch; isResetPage=true");
}
else if(p1 == "btn3") //打印预览
AF.func("PrintPreview", "");
}
//排序事件: 交由服务器排序
else if(Event == "Sort") {
AF.func("bBar.SetObjectProp", "ID0\r\ndataURL\r\n" + genUrl() + "\r\n mode=Asynch; isResetPage=true");
}
}
4.关于事件部分,对Treelist而言,topBar、bottomBar并无区别,只要保证二者内部的输入对象id不重复就行,请自行参考页面的js源码. |