1

我已经在页面中实现了 Telerik 树视图并使用 Web 服务填充节点。 源代码看起来像

    <telerik:RadTreeView ID="tvNodes" runat="server" EnableDragAndDrop="false" ExpandAnimation-Type="OutExpo" ExpandAnimation-Duration="800" EnableDragAndDropBetweenNodes="false" CollapseAnimation-Type="OutElastic" CollapseAnimation-Duration="800" Skin="Windows7" OnNodeDrop="tvNodes_HandleDrop" ClientNodePopulating="nodePopulating">
        <ContextMenus>
            <telerik:RadTreeViewContextMenu ID="NodesTreeMenu" runat="server" CssClass="MenuGroup" Skin="Windows7">
                <CollapseAnimation Type="none" />
            </telerik:RadTreeViewContextMenu>
        </ContextMenus>
        <WebServiceSettings Path="../ManageNode.asmx" Method="GetNodes">
        </WebServiceSettings>
    </telerik:RadTreeView>

Javascript

        function nodePopulating(sender, eventArgs) {
        var node = eventArgs.get_node();
        var context = eventArgs.get_context();
        SelectedType = '1'//selected node id.
        SearchText = ''
        context["ParentID"] = node.get_value();
        context["AllowDragAndDrop"] = allowDragDrop;
        context["SelectedType"] = SelectedType;
        context["SearchText"] = SearchText;
    }

网络方法

        [WebMethod]
    public RadTreeNodeData[] GetNodes(RadTreeNodeData node, object context)
    {
        IDictionary<string, object> contextDictionary = (IDictionary<string, object>)context;
        List<RadTreeNodeData> nodes = new List<RadTreeNodeData>();
        int parentID = Convert.ToInt32(contextDictionary["ParentID"]);
        bool AllowDragAndDrop = Convert.ToBoolean(contextDictionary["AllowDragAndDrop"]);
        int selectedType = Convert.ToInt32(contextDictionary["SelectedType"]);
        string SearchText = Convert.ToString(contextDictionary["SearchText"]);
        dsNodes = NodeBLL.GetAllRecordsByNodeDefinition(selectedType, parentID, SearchText.Trim());
        for (int rowCount = 0; rowCount < dsNodes.Tables[0].Rows.Count; rowCount++)
        {
            DataRow childRow = dsNodes.Tables[0].Rows[rowCount];
            RadTreeNodeData childNode = new RadTreeNodeData();
            if (Convert.ToInt16(childRow["StatusID"]) == Convert.ToInt16(Common.NodeStatus.Archieve))
            {
                childNode.Text = Common.DecodeXML(Convert.ToString(childRow["Name"])) + Common.deleteFlag;
            }
            else
            {
                childNode.Text = Common.DecodeXML(Convert.ToString(childRow["Name"]));
            }
            childNode.Value = Convert.ToString(childRow["ID"]);
            childNode.Attributes.Add(Common.virtualIDAtt, Convert.ToString(childRow["virtualID"]));
            childNode.Attributes.Add(Common.isVirtualExist, Convert.ToString(childRow["isVirtualExist"]));
            childNode.Attributes.Add(Common.NodeDefinitionID, Convert.ToString(childRow["NodeDefinitionID"]));
            childNode.Attributes.Add(Common.ParentNodeID, Convert.ToString(childRow["ParentID"]));
            childNode.Attributes.Add(Common.Position, Convert.ToString(childRow["Position"]));
            childNode.Attributes.Add(Common.NodeDefinition, Convert.ToString(childRow["NodeDefinition"]));

            childNode.ExpandMode = (Convert.ToInt32(childRow["ischildexists"]) > 0) ? TreeNodeExpandMode.WebService : TreeNodeExpandMode.ClientSide;
            nodes.Add(childNode);
        }
     return nodes.ToArray();
    }

当我点击展开箭头然后通过javascript函数调用web方法来填充子节点时,它工作得很好,当父节点有1000多个子节点时,我的性能有问题,我想像用户点击展开一样以批处理模式实现箭头,然后用更多按钮加载 200 个子节点,然后单击更多按钮,然后加载下一个 200 个节点。任何人都可以有实现此功能的想法。

谢谢,穆罕默德萨迪克。

4

0 回答 0