How to handle TreeView ClientSide data binding with WebService

4 posts, 0 answers
  1. Somnath
    Somnath avatar
    43 posts
    Member since:
    Jun 2012

    Posted 28 Sep 2012 Link to this post

    <telerik:RadTreeView ID="rtvResources" runat="server" OnClientNodeClicked="rtvResources_OnClientNodeClicked"
                            OnClientContextMenuItemClicking="rtvResources_OnClientContextMenuItemClicking"
                            OnClientContextMenuShowing="rtvResources_OnClientContextMenuShowing" OnClientNodePopulationFailed="function(o,e){}" >
                            <Nodes>
                                <telerik:RadTreeNode runat="server" Text="Public" AllowDrop="false" CssClass="PUBLIC"
                                    ImageUrl="~/Images/folder-icon.png" Selected="true">
                                </telerik:RadTreeNode>
                                <telerik:RadTreeNode runat="server" Text="My Resources" AllowDrop="false" CssClass="USER"
                                    ImageUrl="~/Images/folder-icon.png">
                                </telerik:RadTreeNode>
                                <telerik:RadTreeNode runat="server" Text="Search Folders" AllowDrop="false" CssClass="SEARCH"
                                    ImageUrl="~/Images/search-folder-icon.png" Value="SEARCH">
                                </telerik:RadTreeNode>
                            </Nodes>
                            <ClientNodeTemplate><span id="#=Value#_span">#=Text#</span> <input type="text" value="#=Text#" style="display:none;width:100px;" id="#=Value#_txtEdit" onblur="javascript:Rename();"></input>
                            </ClientNodeTemplate>
                            <WebServiceSettings Path="ManageResources.aspx" Method="wmGetResources"  />
    </telerik:RadTreeView>
    This is working fine .
    But if I get exception in webservice it throws exption message using alert popup.
    I try to handle with OnClientNodePopulationFailed="function(o,e){}"  but still it shows expetion message in window .Please provide way to handle it.

    Thanks ,
    Somnath

  2. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 01 Oct 2012 Link to this post

    Hello Somnath,

    Would you please specify the error?  Also is this the scenario that you are trying to implement:
    http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/clienttemplates/defaultcs.aspx.

    Kind regards,
    Ivana
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Somnath
    Somnath avatar
    43 posts
    Member since:
    Jun 2012

    Posted 01 Oct 2012 Link to this post

    Yes I am using same scenario provide in the link.

    I want to handle server side exception ,so for testing I threw error is webservice method in that case it showed me error is alert window.
    I dont want to do something else may be redirection depends on the error.

    Is it possible ?

    Thanks & Regards,
    Somnath 

  4. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 03 Oct 2012 Link to this post

    Hello Somnath,

    If you need not to show the alert message when a server exception error is thrown you can subscribe to the OnClientNodePopulationFailed event, as you have already done, and cancel the default action of the event.
    Here is an example:
    function OnClientNodePopulationFailed(sender, args) {
        args.set_cancel(true);
    }
    <telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientNodePopulationFailed="OnClientNodePopulationFailed">
        <ClientNodeTemplate>
                <img src="#= Value #" alt="#= Value #" />
                <span>#= Text #</span>
        </ClientNodeTemplate>
        <Nodes>
            <telerik:RadTreeNode Text="Group A" Value="A" ExpandMode="WebService" />
            <telerik:RadTreeNode Text="Group B" Value="B" ExpandMode="WebService" />
            <telerik:RadTreeNode Text="Group C" Value="C" ExpandMode="WebService" />
            <telerik:RadTreeNode Text="Group D" Value="D" ExpandMode="WebService" />
        </Nodes>
        <WebServiceSettings Path="defaultcs.aspx" Method="GetTeams" />
    </telerik:RadTreeView>
    [WebMethod]
    public static RadTreeNodeData[] GetTeams(RadTreeNodeData node)
    {
        List<Team> data = GetTeams(node.Value);
     
        List<RadTreeNodeData> result = new List<RadTreeNodeData>();
        foreach (Team team in data)
        {
            RadTreeNodeData childNode = new RadTreeNodeData();
            childNode.Text = team.TeamName;
            childNode.Value = team.FlagImageUrl;
            result.Add(childNode);
        }
         throw new ApplicationException("An error occurred while attempting to populate ");
     
        return result.ToArray();
    }

    I hope this is helpful.

    Regards,
    Ivana
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top