ASP.NET RecursiveDataSource

A RecursiveDataSource shares the initialization options. methods and events like the normal DataSource. The only difference with it is that some widgets, like the TreeView read it recursively for each level of child items, passing information about the parent item.

<script type="text/javascript">
jQuery(function ($) {
    window.recursiveRead = function (params, success, error, extra) {
        if (!extra) {
            // if no extra params provided, it means
            // this is a read for the top level item
            $.ajax({
                url: "/api/demo-component-demos"
            }).done(function (data) {
                success(data, false, extra);
            }).fail(function () {
                success([], false, extra);
            });
        }
        else {
            // there is a parent, so get its items from its
            // ChildrenUrl property
            $.ajax({
                url: extra.parent.ChildrenUrl
            }).done(function (data) {
                success(data, false, extra);
            }).fail(function () {
                success([], false, extra);
            });
        }
    };
});
</script>

<shield:ShieldRecursiveDataSource runat="server" ID="dataSource">
    <Remote ReadFunction="recursiveRead" />
</shield:ShieldRecursiveDataSource>

To see it in action, refer to this example.