This is a migrated thread and some comments may be shown as answers.

How to handle TreeView ClientSide data binding with WebService

3 Answers 93 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Somnath
Top achievements
Rank 1
Somnath asked on 28 Sep 2012, 01:39 PM
<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

3 Answers, 1 is accepted

Sort by
0
Ivana
Telerik team
answered on 01 Oct 2012, 08:49 AM
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.
0
Somnath
Top achievements
Rank 1
answered on 01 Oct 2012, 09:22 AM
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 

0
Ivana
Telerik team
answered on 03 Oct 2012, 02:44 PM
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.
Tags
General Discussions
Asked by
Somnath
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Somnath
Top achievements
Rank 1
Share this question
or