• Telerik RadTreeListView示例


            <telerik:RadTreeListView Margin="3"
                    Name="tv" Grid.Row="2"
                    telerik:StyleManager.Theme="Office_Silver" 
                    AutoGenerateColumns="False" 
                    IsFilteringAllowed="False" 
                    HierarchyColumnIndex="1"
                    RowIndicatorVisibility="Collapsed"
                    SelectedCellsChanged="tv_SelectedCellsChanged"
                    IsReadOnly="True">
                <telerik:RadTreeListView.ChildTableDefinitions>
                    <telerik:TreeListViewTableDefinition ItemsSource="{Binding Items}" />
                </telerik:RadTreeListView.ChildTableDefinitions>
                <telerik:RadTreeListView.Columns>
                    <telerik:GridViewSelectColumn />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding ID}" Header="分类编号" IsVisible="False"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding CategoryName}" Header="分类名称" Width="300" />
                </telerik:RadTreeListView.Columns>
            </telerik:RadTreeListView>
    using System;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.Collections.ObjectModel;
    
    namespace SGSGHome.Views.File
    {
        public class CatItem
        {
            public long ID { get; set; }
            public string CategoryName { get; set; }
            public long? ParentID { get; set; }
            public ObservableCollection<CatItem> Items { get; set; }
            public CatItem(long id, string catName, long? parentID)
            {
                this.ID = id;
                this.CategoryName = catName;
                this.ParentID = parentID;
                this.Items = new ObservableCollection<CatItem>();
            }
        }
    }
            public IList<CoreService.FileCategory> CatList { get; set; }
    
            void client_GetFileCategoryListCompleted(object sender, CoreService.GetFileCategoryListCompletedEventArgs e)
            {
                //递归填充TreeListView
                this.CatList = e.Result;
    
                var root = CatList.First(x => x.ParentID == null);
                var rootItem = new CatItem(root.ID, root.CategoryName, null);
                AddChild(root.ID, rootItem);
                tv.ItemsSource = new ObservableCollection<CatItem>() { rootItem };
                tv.AutoExpandItems = true;
            }
    
            //递归方法
            void AddChild(long parentID, CatItem parentItem)
            {
                var filterList = CatList.Where(x => x.ParentID == parentID).ToList();
    
                foreach (var tt in filterList)
                {
                    var childItem = new CatItem(tt.ID, tt.CategoryName, tt.ParentID);
                    parentItem.Items.Add(childItem);
                    var childrenList = CatList.Where(x => x.ParentID == tt.ID).ToList();
                    if (childrenList.Count > 0)
                    {
                        AddChild(tt.ID, childItem);
                    }
                }
            }
  • 相关阅读:
    用户身份与文件权限
    W3school——javascript笔记
    第十一章——常用的Web应用程序
    探究CBV视图
    Django objects.all()、objects.get()与objects.filter()之间的区别介绍
    RTX检索COM 类工厂出错
    Oracle存储过程实例
    Oracle返回数据集
    Oracle数据库创建表空间、创建表、授权
    JS传参出现乱码的种种分析
  • 原文地址:https://www.cnblogs.com/ncore/p/2784553.html
Copyright © 2020-2023  润新知