PDA

View Full Version : [CLOSED] Get CheckedNode codebehind?



gs_user
Apr 17, 2012, 1:46 AM
Hi,
how to get childnode has been checked
without use javascript ,only use c#

the sample use javascript


<script type="text/javascript">
var getTasks = function () {
var msg = "",
selChildren = App.TreePanel1.getChecked();

Ext.each(selChildren, function (node) {
if (msg.length > 0) {
msg += ", ";
}

msg += node.data.text;
});

Ext.Msg.show({
title : "Completed Tasks",
msg : msg.length > 0 ? msg : "None",
icon : Ext.Msg.INFO,
minWidth : 200,
buttons : Ext.Msg.OK
});
};
</script>

we want to use C# to get checkednode...

thank you

Daniil
Apr 17, 2012, 11:52 AM
Hi,

Please use the TreePanel Checked Nodes property.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void GetChecked(object sender, DirectEventArgs e)
{
StringBuilder s = new StringBuilder();

if (this.TreePanel1.CheckedNodes != null)
{
foreach (SubmittedNode node in this.TreePanel1.CheckedNodes)
{
s.AppendFormat("{0}<br/>", node.Text);
}
}
else
{
s.Append("No checked nodes");
}

X.Msg.Alert("Checked", s).Show();
}
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:TreePanel ID="TreePanel1" runat="server" AutoHeight="true">
<Root>
<ext:Node Text="Root" Expanded="true" Checked="false">
<Children>
<ext:Node Text="Node1" Expanded="true" Checked="false">
<Children>
<ext:Node Text="Node11" Expanded="true" Checked="false">
<Children>
<ext:Node Text="Node11" Leaf="true" Checked="false" />
<ext:Node Text="Node112" Leaf="true" Checked="false" />
</Children>
</ext:Node>
</Children>
</ext:Node>
</Children>
</ext:Node>
</Root>
</ext:TreePanel>
<ext:Button runat="server" Text="Get checked nodes" OnDirectClick="GetChecked" />
</form>
</body>
</html>

gs_user
Apr 19, 2012, 8:07 AM
tree panel was build codebehind...
I can not use checked Nodes property



Hi,

Please use the TreePanel Checked Nodes property.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void GetChecked(object sender, DirectEventArgs e)
{
StringBuilder s = new StringBuilder();

if (this.TreePanel1.CheckedNodes != null)
{
foreach (SubmittedNode node in this.TreePanel1.CheckedNodes)
{
s.AppendFormat("{0}<br/>", node.Text);
}
}
else
{
s.Append("No checked nodes");
}

X.Msg.Alert("Checked", s).Show();
}
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:TreePanel ID="TreePanel1" runat="server" AutoHeight="true">
<Root>
<ext:Node Text="Root" Expanded="true" Checked="false">
<Children>
<ext:Node Text="Node1" Expanded="true" Checked="false">
<Children>
<ext:Node Text="Node11" Expanded="true" Checked="false">
<Children>
<ext:Node Text="Node11" Leaf="true" Checked="false" />
<ext:Node Text="Node112" Leaf="true" Checked="false" />
</Children>
</ext:Node>
</Children>
</ext:Node>
</Children>
</ext:Node>
</Root>
</ext:TreePanel>
<ext:Button runat="server" Text="Get checked nodes" OnDirectClick="GetChecked" />
</form>
</body>
</html>

Daniil
Apr 19, 2012, 9:36 AM
tree panel was build codebehind...
I can not use checked Nodes property

Why not? Please provide the code how you create a TreePanel.