2014-10-29 54 views
0

我正在關注儀表板的加載事件,但無法在我的項目中部署此項目。任何人都可以幫助我找到正確的方法。DevExpress mvc擴展:如何將對象綁定到asp.net中的DashboardSourceModel mvc5

這裏是我的控制器

 public ActionResult Demo() 
    { 
     return View(); 
    } 


    [ValidateInput(false)] 
    public ActionResult DemoDashboardViewerPartial() 
    { 
     return PartialView("_DemoDashboardViewerPartial", DemoDashboardViewerSettings.Model); 
    } 
    public FileStreamResult DemoDashboardViewerPartialExport() 
    { 
     return DashboardViewerExtension.Export("DemoDashboardViewer", DemoDashboardViewerSettings.Model); 
    } 
    class DemoDashboardViewerSettings 
    { 
     public static DashboardSourceModel Model 
     { 
      get 
      { 
       return DashboardSourceModel(); 
      } 
     } 

     private static DashboardSourceModel DashboardSourceModel() 
     { 
      DashboardSourceModel model = new DashboardSourceModel(); 
      model.DashboardSource = typeof(IDBOWeb.Code.Dashboards.Dashboard1); 
      return model; 
     } 
    } 

我試圖通過綁定對象添加數據源到一個餡餅項目添加到儀表板和傳遞的參數和值餡餅項目。 這裏是我的dashboard1.cs:

namespace IDBOWeb.Code.Dashboards 
    { 
    public partial class Dashboard1 : DevExpress.DashboardCommon.Dashboard 
    { 
    public Dashboard1() 
    { 
     InitializeComponent(); 


    } 

    private void Dashboard1_DashboardLoading(object sender, EventArgs e) 
    { 
     Dashboard dashboard = new Dashboard(); 
     var data = new suggestReport().GetData(); 
     dashboard.AddDataSource("Data Source 1",data); 

     PieDashboardItem pie = new PieDashboardItem(); 
     pie.DataSource = dashboard.DataSources[0]; 
     pie.Arguments.Add(new Dimension("Russia")); 
     pie.Values.Add(new Measure("Open")); 
     pie.Values.Add(new Measure("Closed")); 


     dashboard.Items.Add(pie); 
     //pieDashboardItem1.Dashboard = dashboard; 

    } 

    private void Dashboard1_DataLoading(object sender, DashboardDataLoadingEventArgs e) 
    { 
     e.Data = new suggestReport().GetData(); 
    } 

    } 
    } 

回答

0

終於它的工作做如下。

 namespace IDBOWeb.Code.Dashboards 
{ 
public partial class Dashboard1 : DevExpress.DashboardCommon.Dashboard 
{ 
public Dashboard1() 
{ 
    InitializeComponent(); 


} 

private void Dashboard1_DataLoading(object sender, DashboardDataLoadingEventArgs e) 
{ 
    e.Data = GetUserSessionCount(); //use a private function returning a list of object 
} 
private List<DashBoardUserSessionDetails> GetUserSessionCount() 
    { 

     List<DashBoardUserSessionDetails> userList = proxy.GetUserSessionCounts();//get the listed object 

     return userList; 
    } 

} 
} 
相關問題