PDA

View Full Version : [CLOSED] tree panel in the componentcolumn?



hdsoso
Nov 19, 2013, 2:13 PM
i have a tree panel , and his tree store have three modefields , they are id, type, pid. id is the primary key, type is the name of type, pid is the parent id .
please see the picture
7230
i use ComponentColumn which DataIndex="pid", and place a tree panel to the ComponentColumn,
because the inner treepanel is same as the outer treepanel , so i want to use same treestore which id is "ts_product_type", i try to place the treestore in the bin property , but failed. can you give me an advice ?
below is my code:


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="product_type.aspx.cs" Inherits="extdemo.admin.pages.product_type" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" SourceFormatting="True"></ext:ResourceManager>


<ext:Viewport runat="server">

<Items>

<ext:TreePanel ID="tp_product_type" runat="server" Title="商品类别管理">
<Store>
<ext:TreeStore runat="server" ID="ts_product_type" OnReadData="LoadProductTypes">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="id"></ext:ModelField>
<ext:ModelField Name="type"></ext:ModelField>
<ext:ModelField Name="pid"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
<Proxy>
<ext:PageProxy />
</Proxy>
</ext:TreeStore>
</Store>
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" Text="新增"></ext:Button>
</Items>
</ext:Toolbar>
</TopBar>

<Root>
<ext:Node Expanded="true" NodeID="-1">
<CustomAttributes>
<ext:ConfigItem Name="id" Value="-1" />
<ext:ConfigItem Name="type" Value="根节点" />
</CustomAttributes>
</ext:Node>
</Root>
<ColumnModel>
<Columns>
<ext:Column runat="server" DataIndex="id" Text="编号"></ext:Column>
<ext:TreeColumn runat="server" DataIndex="type" Text="类别" Flex="1">
<Editor>
<ext:TextField runat="server"></ext:TextField>
</Editor>
</ext:TreeColumn>
<ext:ComponentColumn runat="server" DataIndex="pid" Text="父类别">
<Component>
<ext:TreePanel runat="server" StoreID="ts_product_type">// here can not recognise the store ts_product_type
<Root>
<ext:Node Expanded="true" NodeID="-1">
<CustomAttributes>
<ext:ConfigItem Name="id" Value="-1" />
<ext:ConfigItem Name="type" Value="根节点" />
</CustomAttributes>
</ext:Node>
</Root>
<ColumnModel>
<Columns>
<ext:TreeColumn ID="TreeColumn1" runat="server" DataIndex="type" Text="类别" Flex="1">
<Editor>
<ext:TextField ID="TextField1" runat="server"></ext:TextField>
</Editor>
</ext:TreeColumn>
</Columns>
</ColumnModel>
</ext:TreePanel>
</Component>
</ext:ComponentColumn>
</Columns>
</ColumnModel>
<Plugins>
<ext:CellEditing runat="server"></ext:CellEditing>
</Plugins>
</ext:TreePanel>
</Items>
</ext:Viewport>

</form>
</body>
</html>





using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
using Service;

namespace extdemo.admin.pages
{
public partial class product_type : System.Web.UI.Page
{
readonly ProductTypeService _productTypeService = new ProductTypeService();
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
tp_product_type.ExpandAll();
LoadAllProductType();
}
}
private void LoadAllProductType()
{
// tp_product_type1.Root.Add(new Node{Text = "new",NodeID = "1"});
}
public void LoadProductTypes(object sender, NodeLoadEventArgs e)
{
var pds = _productTypeService.GetChildProduct(int.Parse(e.No deID));
foreach (var qizProductType in pds)
{
var n = new Node { Leaf = _productTypeService.IsLeaf(qizProductType.id), NodeID = qizProductType.id.ToString(CultureInfo.InvariantCu lture) };
n.CustomAttributes.Add(new ConfigItem { Name = "pid", Value = qizProductType.pid.ToString() });
n.CustomAttributes.Add(new ConfigItem { Name = "type", Value = qizProductType.type });
n.CustomAttributes.Add(new ConfigItem { Name = "id", Value = qizProductType.id.ToString(CultureInfo.InvariantCu lture) });
e.Nodes.Add(n);
}
}
}
}

Daniil
Nov 19, 2013, 5:45 PM
Hi @hdsoso,

Please try to put the TreeStore before the Viewport.

P.S. But we doubt that sharing the same TreeStore between parent and inner TreePanels is going to work.

hdsoso
Nov 29, 2013, 12:25 AM
Hi @hdsoso,

Please try to put the TreeStore before the Viewport.

P.S. But we doubt that sharing the same TreeStore between parent and inner TreePanels is going to work.

could you give me an example which uses TreePanel as a component of ComponentColumn ?

Daniil
Nov 29, 2013, 4:02 AM
We have no such an example.

And I am not sure it is going to work at all. It is kind of quirky to put a TreePanel into a TreePanel.