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

Help required with OnClientNodePopulationFailed event

5 Answers 69 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 29 Apr 2010, 12:43 PM
Hi,

Is there any way of getting the http error code when this result fires?  In my application (asp.net mvc) I am returning a 403 Forbidden code when the forms authentication for the user times out.

In my other ajax calls to the app, the code is available and I am redirecting the users to the login page if appropriate. An example of this would be the ClientNodeDropping event

//handles node dropping event. 
function clientNodeDropping(sender, eventArgs) { 
  //Get source and destination nodes. 
  var srcNode = eventArgs.get_sourceNode(); 
  var destNode = eventArgs.get_destNode(); 
  //Get values needed to update a folder or reports location. 
  var srcId = srcNode.get_value(); 
  var srcType = srcNode.get_attributes().getAttribute("nodeType"); 
  var destId; 
  var destType; 
  try { 
    destId = destNode.get_value(); 
    destType = destNode.get_attributes().getAttribute("nodeType"
  } 
  catch (e) { 
    destId = 0; 
    desttype = "Folder"
  } 
  //Check that destination node is not of "Report" nodeType. 
  if (destType != "Report") { 
    $.ajax({ 
      type: "POST"
      url: "/Reports/MoveNode/"
      data: ({ sourceId: srcId, destinationId: destId, srcNodeType: srcType, destNodeType: destType }), 
      dataType: "json"
      success: function(response) { 
        if (response.Success) { 
          clientNodeDroppingSuccess(srcNode, destNode, srcType, destType); 
        } 
        else { 
          alert(response.Errors[0]); 
          eventArgs.set_cancel(true); 
        } 
      }, 
      error: function(xhr, state, errorThrown) { 
        switch (xhr.status) { 
          case 403: 
            window.location = window.location
            break
          default: 
            alert("Sorry, that action could not be performed at this time."); 
            eventArgs.set_cancel(true); 
            break
        } 
      } 
    }); 
  } 

How can I achieve this with the OnClientNodePopulationFailed event?

Thanks,
Nick

5 Answers, 1 is accepted

Sort by
0
Dimitar Milushev
Telerik team
answered on 05 May 2010, 01:15 PM
Hi Nick,

This is not currently possible with RadTreeView. I'll make sure to log this as a feature request in our system so it can be implemented in a future version.

You may want to check the Telerik MVC TreeView Component which will be better suited for this scenario.

All the best,
Dimitar Milushev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Nick
Top achievements
Rank 1
answered on 05 May 2010, 01:23 PM
Dimitar,

Thanks for the reply.  I would prefer to use the MVC TreeView but all the TreeViews in this page are using the context menu capability which is not available as far as I am aware on the MVC TreeView.

Are context menus planned for the MVC TreeView at any point?

Nick
0
Atanas Korchev
Telerik team
answered on 06 May 2010, 02:24 PM
Hi Nick,

You can check the example attached in this forum thread. It shows how to use a context menu with the MVC treeview.

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Nick
Top achievements
Rank 1
answered on 06 May 2010, 04:45 PM
Hi Atanas,

That does potentially look like it could replace what I have. 

Is it easy to hook into the onDoubleClick event on the client?  I didn't see this listed in the available client-side events.

What I need to replace is the following treeview where a double-click will either expand the node if it's a folder or pop up a dialog if it's a report node:

      <telerik:RadTreeView ID="rtv4" runat="server"  
                           Category="4"  
                           AllowNodeEditing="false"  
                           EnableDragAndDrop="true"  
                           EnableDragAndDropBetweenNodes="true"  
                           OnClientLoad="treeClientLoad"  
                           OnClientContextMenuItemClicking="onReportContextMenuItemClicking"  
                           OnClientDoubleClick="clientDoubleClick"  
                           OnClientNodeDropping="clientNodeDropping"  
                           OnClientNodeEditing="rtvNodeEditing"  
                           OnClientNodePopulationFailed="clientNodePopulationFailed" 
                           Skin="Default"
        <WebServiceSettings Path="~/Reports" Method="LoadNodes" /> 
        <ContextMenus> 
          <telerik:RadTreeViewContextMenu ID="reportMenu" runat="server" EnableEmbeddedSkins="false" Skin="Attenda"
            <Items> 
              <telerik:RadMenuItem Value="viewReport" Text="View Report" ToolTip="View this report" /> 
              <telerik:RadMenuItem Value="renameReport" Text="Rename Report" ToolTip="Rename this report" /> 
              <telerik:RadMenuItem Value="copyReport" Text="Copy Report" ToolTip="Copies selected report." /> 
              <telerik:RadMenuItem Value="editReport" Text="Edit Report Parameters" ToolTip="Edit report parameters" /> 
              <telerik:RadMenuItem Value="deleteReport" Text="Delete Report" ToolTip="Delete report" /> 
            </Items> 
          </telerik:RadTreeViewContextMenu> 
          <telerik:RadTreeViewContextMenu ID="folderMenu" runat="server" EnableEmbeddedSkins="false" Skin="Attenda"
            <Items> 
              <telerik:RadMenuItem Value="runAllReports" Text="Run All Reports In Folder" /> 
              <telerik:RadMenuItem Value="renameFolder" Text="Rename Folder" /> 
              <telerik:RadMenuItem Value="addFolder" Text="Add New Folder" /> 
              <telerik:RadMenuItem Value="deleteFolder" Text="Delete" /> 
            </Items> 
          </telerik:RadTreeViewContextMenu> 
        </ContextMenus> 
      </telerik:RadTreeView> 
 

When the user double clicks a node this function is called:
//Handles client double click. 
function clientDoubleClick(sender, eventArgs) { 
  var node = eventArgs.get_node(); 
  // Check for report node 
  var nodeType = node.get_attributes().getAttribute("nodeType"); 
  if (nodeType == "Report") { 
    // Show report dialog 
    viewReport(node.get_value()); 
  } 

0
Atanas Korchev
Telerik team
answered on 12 May 2010, 08:09 AM
Hi Nick,

You can bind to any event using jQuery. Here is an example for the doubleclick event:

$('#TreeView .t-item').live('dblclick', function(e){
      alert('doubleclick');
      e.stopPropagation();
});

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TreeView
Asked by
Nick
Top achievements
Rank 1
Answers by
Dimitar Milushev
Telerik team
Nick
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or