<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<
head
runat
=
"server"
>
<
title
>Ext.NET Example</
title
>
<
script
type
=
"text/javascript"
>
var onClick = function (node, e) {
var t = Ext.get(e.getTarget()),
cls,
index;
if (!t.hasClass("x-treegrid-col")) {
t = t.up(".x-treegrid-col");
}
cls = t.getAttribute("class");
index = parseInt(cls.substr(cls.length - 1));
if (!Ext.isNumber(index)) {
index = 0;
}
Ext.Msg.alert("Click", String.format("Node id: {0}<
br
/>Column index: {1}", node.id, index));
};
</
script
>
</
head
>
<
body
>
<
ext:ResourceManager
runat
=
"server"
/>
<
ext:TreeGrid
runat
=
"server"
AutoHeight
=
"true"
>
<
Columns
>
<
ext:TreeGridColumn
Header
=
"Text"
DataIndex
=
"text"
Width
=
"100"
/>
<
ext:TreeGridColumn
Header
=
"Test1"
DataIndex
=
"test1"
Width
=
"100"
Cls
=
"my-column1"
/>
<
ext:TreeGridColumn
Header
=
"Test2"
DataIndex
=
"test2"
Width
=
"100"
Cls
=
"my-column2"
/>
</
Columns
>
<
Root
>
<
ext:TreeNode
>
<
Nodes
>
<
ext:TreeNode
Text
=
"Node1"
>
<
CustomAttributes
>
<
ext:ConfigItem
Name
=
"test1"
Value
=
"node1_test1"
Mode
=
"Value"
/>
<
ext:ConfigItem
Name
=
"test2"
Value
=
"node1_test2"
Mode
=
"Value"
/>
</
CustomAttributes
>
<
Nodes
>
<
ext:TreeNode
Text
=
"Node1.1"
>
<
CustomAttributes
>
<
ext:ConfigItem
Name
=
"test1"
Value
=
"node1.1_test1"
Mode
=
"Value"
/>
<
ext:ConfigItem
Name
=
"test2"
Value
=
"node1.1_test2"
Mode
=
"Value"
/>
</
CustomAttributes
>
</
ext:TreeNode
>
</
Nodes
>
</
ext:TreeNode
>
</
Nodes
>
</
ext:TreeNode
>
</
Root
>
<
Listeners
>
<
Click
Fn
=
"onClick"
/>
</
Listeners
>
</
ext:TreeGrid
>
</
body
>
</
html
>
摘自:http://forums.ext.net/showthread.php?17775-CLOSED-Treegrid-determine-what-column-was-clicked-on