如何延迟加载Infragistics UltraWebTree控件? [英] How to lazy load Infragistics UltraWebTree control?

查看:80
本文介绍了如何延迟加载Infragistics UltraWebTree控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到任何有关如何延迟加载Infragistics UltraWebTree v6.3的示例

I cannot find any examples of how to lazy load the Infragistics UltraWebTree v6.3

我发现Infragistics网站上的文档往往仅限于其控件的最新版本,但这是旧版应用程序,我无法升级.有没有人获得示例代码或链接来演示如何在此控件中延迟加载节点?

I found that the docs on the Infragistics site tend to be limited to the latest version of their controls, but this is a legacy app which I am unable to upgrade. Has anyone got example code or links which demonstrate how to lazy-load nodes in this control?

我们当前加载的实现是加载1.35MB的html,因为它填充了整个树! kes!

The current implementation that we have loads 1.35MB of html because it is populating the entire tree!! Yikes!

推荐答案

事实证明,它只是一个简单的JQuery和一个Web服务,用于返回渲染的节点.

It turnedout to be a simple piece of JQuery and a webservice to return the rendered nodes.

任何带有子项的节点都将使用文本正在加载..."进行初始化,以便脚本知道尝试检索它们.

Any node that has sub-items is initialised with the text "Loading..." so that the script knows to attempt to retrieve them.

<script type="text/javascript" language="javascript">
    var imageTypeExpression = "img[imgType='exp'][src$='plus.gif']";
    var maxRetries = 5;
    jQuery(document).ready(function() {
        jQuery("#T_TreeListCtl " + imageTypeExpression).click(imageClick);
        jQuery("#tdLists").show();
    });

    function imageClick() {
        var parentDivId = jQuery(this).parent().attr('id');
        var nodesDiv = '#M_' + parentDivId;
        if (jQuery(nodesDiv).text() == 'Loading...') {
            getNodes(parentDivId, nodesDiv, maxRetries);
        }
    }

    function getNodes(parentDivId, nodesDiv, retryCount){
        if (retryCount == 0) {
            jQuery(nodesDiv).html("<div>Loading... failed.</div>");
        }
        else {
            jQuery.ajax({ type: "POST",
                url: "WebServices/TreeNodes.asmx/GetChildNodes",
                data: "{'parentId' :'" + parentDivId + "'}",
                dataType: "json",
                contentType: 'application/json; charset=utf-8',
                success: function(json) {
                    var result = eval("(" + json.d + ")");
                    jQuery(nodesDiv).html(result.value);
                    jQuery(imageTypeExpression, nodesDiv).click(imageClick);
                },
                timeout: 100,
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    if (textStatus == 'timeout') {
                        getNodes(parentDivId, nodesDiv, retryCount - 1); //keep trying
                    }
                }
            });
        }
    }
</script>

这篇关于如何延迟加载Infragistics UltraWebTree控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆