Sep 26, 2012, 6:55 PM
Checked is always false on TreePanel submit nodes.
I have a simplified example and it seems that "Checked" for every node, including root is false. After some searching, I added this to my click listener's handler:
App.tpPermissions.updateCheckSelection();
Default.aspx:<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="Ext.NET_2_Site.Default" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Dynamic Nodes - Tree Panel</title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" IDMode="Explicit" />
<ext:TreePanel ID="tpPermissions" runat="server" RootVisible="true" AutoScroll="true"
Title="Permissions" Width="500" UseArrows="true" Icon="Link" Animate="false"
OnSubmit="SubmitNodes" Height="500">
<Store>
<ext:TreeStore ID="TreeStore1" runat="server">
<Proxy>
<ext:AjaxProxy Url="TreePanelHandler.ashx" />
</Proxy>
</ext:TreeStore>
</Store>
<Root>
<ext:Node NodeID="root" Text="Root" Checked="false" />
</Root>
<BottomBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="btnSave" runat="server" Text="Save" Icon="Disk">
<Listeners>
<Click Handler="App.tpPermissions.updateCheckSelection();#{tpPermissions}.submitNodes();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</BottomBar>
</ext:TreePanel>
</body>
</html>
Default.aspx.cs:using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
namespace Ext.NET_2_Site
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SubmitNodes(object sender, SubmitEventArgs e)
{
var chk2 = tpPermissions.CheckedNodes;
var nodes = e.RootNode.Children;
var chk = nodes.Where(n => n.Checked);
//chk2 is null, nodes has everything but checked is always false, and chk is empty
}
}
}
TreePanelHandler.ashx.csusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Ext.Net;
namespace Ext.NET_2_Site
{
/// <summary>
/// Summary description for TreePanelHandler
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class TreePanelHandler : IHttpHandler
{
public HttpContext Context { get; set; }
public void ProcessRequest(HttpContext context)
{
Context = context;
context.Response.ContentType = "text/plain";
string nodeId = context.Request["node"];
if (string.IsNullOrEmpty(nodeId))
{
NodeCollection nodes = new NodeCollection(false);
context.Response.Write(nodes.ToJson());
context.Response.End();
}
else if (nodeId == "root")
{
NodeCollection nodes = new NodeCollection(false);
Ext.Net.Node sn = new Ext.Net.Node();
sn.Text = "Site";
sn.Icon = Icon.WorldLink;
sn.NodeID = "1";
Ext.Net.Node an = new Ext.Net.Node();
an.Text = "Application";
an.Icon = Icon.ApplicationLink;
an.NodeID ="2";
Ext.Net.Node pn = new Ext.Net.Node();
pn.Text = "Permission";
pn.Icon = Icon.Link;
pn.NodeID = "3";
pn.Leaf = true;
pn.Checked = false;
an.Children.Add(pn);
sn.Children.Add(an);
nodes.Add(sn);
context.Response.Write(nodes.ToJson());
context.Response.End();
}
else
{
NodeCollection nodes = new NodeCollection(false);
context.Response.Write(nodes.ToJson());
context.Response.End();
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
Last edited by Uziel; Sep 26, 2012 at 7:09 PM.