asp.net - How to lazy load Infragistics UltraWebTree control? -
i cannot find examples of how lazy load infragistics ultrawebtree v6.3
i found docs on infragistics site tend limited latest version of controls, legacy app unable upgrade. has got example code or links demonstrate how lazy-load nodes in control?
the current implementation have loads 1.35mb of html because populating entire tree!! yikes!
it turnedout simple piece of jquery , webservice return rendered nodes.
any node has sub-items initialised text "loading..." script knows attempt 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>
Comments
Post a Comment