Click here to Skip to main content
15,568,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have created one tree view in devexpress in which I am displaying items in the different folders in App_Data folder.

If i click on any node i need to display particular dashboard in the dashboard viewer.

I have created 2 partial views for tree view and dashboard viewer.

If i click on that treeview node then I need to retrieve the path of that node and that i have to pass it to the model in which dashboard is loading.

What I have tried:

My Views

DashboardViewer1Partial.cshtml
HTML
@model DevExpress.DashboardWeb.Mvc.DashboardSourceModel
@Html.DevExpress().DashboardViewer(settings => {
	settings.Name = "DashboardViewer1";
	settings.CallbackRouteValues = new { Controller = "Home", Action = "DashboardViewer1Partial" };
	settings.ExportRouteValues = new { Controller = "Home", Action = "DashboardViewer1PartialExport" };
    settings.AllowExportDashboardItems = true;
    settings.Width = new Unit("100%");
    settings.Height = new Unit("800px");
}).BindToSource(Model).GetHtml()


VirtualModePartial.cshtml

HTML
@model AINIPMKPIDashboard_New.Models.TreeViewHelper
@Html.DevExpress().TreeView(
    settings =>
    {
        settings.Name = "tvVirtualMode";
        settings.CallbackRouteValues = new { Controller = "TreeView", Action = "VirtualModePartial" };
        settings.Images.NodeImage.Width = 13;
        settings.Styles.NodeImage.Paddings.PaddingTop = 3;
        settings.Styles.NodeImage.Paddings.PaddingLeft = 3;
        settings.ClientSideEvents.NodeClick = "OnTreeViewNodeClick";
    }).BindToVirtualData(AINIPMKPIDashboard_New.Models.TreeViewHelper.CreateChildren).GetHtml()


My Controller

using DevExpress.DashboardWeb.Mvc;

namespace AINIPMKPIDashboard_New.Controllers
{
    public class HomeController : Controller
    {
        //public override string Name { get { return "TreeView"; } }
        public ActionResult Index()
        {
            return View();
        }

        [ValidateInput(false)]
        public ActionResult DashboardViewer1Partial()
        {
            return PartialView("_DashboardViewer1Partial", DashboardViewer1Settings.Model);
        }
        public FileStreamResult DashboardViewer1PartialExport()
        {
            return DevExpress.DashboardWeb.Mvc.DashboardViewerExtension.Export("DashboardViewer1", DashboardViewer1Settings.Model);
        }
    }
    class DashboardViewer1Settings
    {
        public static DevExpress.DashboardWeb.Mvc.DashboardSourceModel Model
        {
            get
            {
                return DashboardSourceModel();
            }
        }
        private static DashboardSourceModel DashboardSourceModel()
        {
            DashboardSourceModel model = new DashboardSourceModel();
            model.DashboardSource = System.Web.Hosting.HostingEnvironment.MapPath(@"~\App_Data\Dashboards\IP_KPI_CENTER_13.8_FORECAST\Responder_Metadata_Backlog_13.8_Forecast.xml"); // Need to pass the parameter and replace the path here 
            return model;
        }
    }
}
Posted
Updated 6-Aug-17 1:42am
v3
Comments
Graeme_Grant 28-Jul-17 5:58am    
As this is a DevExpress control, you have pre-paid support under your subscription. Please refer to their documentation or contact their support for help.
TarunKumarSusarapu 28-Jul-17 6:26am    
Its a basic MVC Flow.Please suggest me

1 solution

Implement an onclick event, where make an Ajax request to a controller method in which you are return VirtualModePartial.cshtml. In Ajax call pass your required parameter as a Json response and pass these parameters to partial view like.

Ajax Call:
$.ajax({
    url: '@Url.Action("Controller", "MethodName")',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    data:{Id:2},   //This is passing parameter 
    success: function(data){
      $("DashBoard").html=data; //Data contain your whole resultant partial view that is being display in DashBoard container as a 'div' in this page
    },
    error: errorFunc
});


Controller Method:

ActionResult Method(int Id){ //instead of Id, you can pass an complex parameter in json response
return View("PartionalViewPath",Id);
}
 
Share this answer
 
Comments
TarunKumarSusarapu 7-Aug-17 6:18am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900