PDA

View Full Version : Partial View Not Loading Properly



massman07
Jul 17, 2014, 9:52 PM
Hi,

I have a Microsoft chart inside a partial view as such:



@model System.Data.DataTable

@{
var myChart = new System.Web.Helpers.Chart(width: 500, height: 300)
.AddTitle("Chart Title")
//.DataBindTable(@Model.DefaultView, xField: @Model.Columns[0].ColumnName)
.AddSeries(
chartType: "Bar",
xValue: @Model.DefaultView, xField: @Model.Columns[0].ColumnName,
yValues: @Model.DefaultView, yFields: @Model.Columns[1].ColumnName
)
.Write();
}

I want to have this view loaded inside a panel as such:


X.Panel()
.Region(Region.East)
.Split(true)
.Collapsible(true)
.Frame(true)
.ID("ChartsPanel")
.Items(
X.Panel()
.ID("Chart1")
.Content(@<img src="@Url.Action("RenderChart")"/>)
.Region(Region.North),
X.Panel()
.ID("ChartControls")
.Region(Region.South)
.Items(
X.ComboBox()
.Text("Chart Type")
.Border(false)
.Items(
new ListItem("Bar", "BE"),
new ListItem("Column", "BR"),
new ListItem("Pie", "BG"),
new ListItem("Box Plot", "CA"),
new ListItem("Radar", "CL"),
new ListItem("Scatter", "CY"),
new ListItem("Line", "FI")
)

The controller action I am using to load the partial view:


public Ext.Net.MVC.PartialViewResult RenderChart(string containerId)
{
return new Ext.Net.MVC.PartialViewResult
{
Model = SessionHelper.dbTable,
ViewName = "RenderChart",
ContainerId = containerId
};
}

When I run RenderChart() from Index() action, "Chart1" panel remains empty and my gridpanel also becomes empty.
Is it possible to do what I am trying to accomplish?

Daniil
Jul 21, 2014, 2:09 PM
Hi @massman07,

Please try

.ContentFromPartial("RenderChart")
instead of

.Content(@<img src="@Url.Action("RenderChart")"/>)
and do not call .RenderChart() for the Index controller action.

Also, I think you might need to use System.Web.MVC.PartialViewResult instead of Ext.Net.MVC.PartialViewResult.

The second one is supposed to be used during DirectEvents/DirectMethods only or some specific cases as it is here:
http://mvc.ext.net/#/Items/ASPX_Engine/