利用extpb.net进行开发,免不了需要自己扩展js的功能,所以我们将一些常见功能进行封装,然后在OpenSheet.aspx.cs中统一加载:
//注册需要的公共js文件
this.ClientScript.RegisterClientScriptInclude("MyCommon", "/ExtPB.Net/MyCommon.js")
以下是对客户端的TreeView 控件进行扩展的一个方法--查找节点项
if (typeof (FINDNODETYPE) == "undefined") {
var FINDNODETYPE = {
Data: 0,
Label: 1
}
}
if (typeof (MATCHINGTYPE) == "undefined") {
var MATCHINGTYPE = {
Exact: 0,
Vague: 1
}
}
//#region Ex_FindNode - 查找节点项
TreeView.prototype.Ex_FindItem = function (handle, findNodeType, findContent, matchingType) {
var tvItem = new TreeViewItem();
var l_found_handle = 0;
var l_child_handle = 0;
while (handle != -1) {
this.GetItem(handle, tvItem);
var id = tvItem.GetData().toString();
var label = tvItem.GetLabel();
if (findNodeType == FINDNODETYPE.Data)
var value = id; //按节点Data域查找
else var value = label; //按节点Label域查找
if (matchingType == MATCHINGTYPE.Exact) { //精确匹配
if (value == findContent) {
return handle;
}
}
else { //模糊匹配(对字符型数据,未做检查)
if (value.indexOf(findContent) >= 0) {
return handle;
}
}
////上面不检查多项
//判断 handle 项是否有子项,有,则递归调用
if (tvItem.GetChildren()) { //有子项
l_child_handle = this.FindItem(TREENAVIGATION.ChildTreeItem, handle);
if (l_child_handle > 0) {
l_found_handle = this.Ex_FindItem(l_child_handle, findNodeType, findContent, matchingType);
}
}
if (l_found_handle > 0) return l_found_handle;
handle = this.FindItem(TREENAVIGATION.NextTreeItem, handle);
}
return -1;
}
//#endregion
阅读(1679) | 评论(0) | 转发(1) |