Hi,
The idea is to create a dynamic chart based on dynamic data (number of clusters defines: Y1, Y2, Y3, Y4, ...)

This example on tradition ASP.NET Web Application works fine, but in MVC, the Store and the other components of the chart are empty (Axes, Series) on "Reload Data" button.

How can I resolve it ?

View

@using Ext.Net;
@using Ext.Net.MVC;

@{    
    var X = Html.X();
}

<!DOCTYPE html>


<html>
<head>
    <script>
        var saveChart = function (btn) {
            Ext.MessageBox.confirm('Confirm Save', 'Save Chart to an image?', function (choice) {
                if (choice == 'yes') {
                    btn.up('panel').down('chart').save({
                        type: 'image/png'
                    });
                }
            });
        };
       
    </script>
</head>
<body>
    @(X.Panel()
        .ID("pnlChart")
        .Title("Line Chart")
        .Layout(LayoutType.Fit)
        .Width(800)
        .Height(600)
        .TopBar(X.Toolbar()
            .Items(               
                X.Button()
                    .Text("Reload Data")
                    .Icon(Icon.ArrowRefresh)
                    .DirectEvents(de =>
                    {
                        de.Click.Url = Url.Action("ReloadData", "Chart");
                        de.Click.Method = HttpMethod.GET;
                    }),
                X.Button()
                    .Text("Save Chart")
                    .Icon(Icon.Disk)
                    .Handler("saveChart"),               
                X.Button()
                    .Text("Animate")
                    .Icon(Icon.ShapesManySelect)
                    .EnableToggle(true)
                    .Pressed(true)
                    .Listeners(l =>
                    {
                        l.Toggle.Handler = "#{chtKpi}.animate = pressed ? {easing: 'ease', duration: 500} : false;";
                    })
            )
        )
        .Items(
        X.Chart()
            .ID("chtKpi")
            .StyleSpec("background:#fff;")
            .Shadow(true)
            .StandardTheme(StandardChartTheme.Category1)
            .Animate(true)
            .LegendConfig(X.ChartLegend().Position(LegendPosition.Bottom))
            .Store(X.Store()
                .ID("stoData")
                .AutoDataBind(true)
                .Data(Model)
                .Model(X.Model()
                    .ID("mdlData")
                    .Fields(
                        X.ModelField().Name("X"),
                        X.ModelField().Name("Y1")
                    )
                )
            )
            .Axes(
                X.NumericAxis()
                    .Fields(new[] { "Y1" })
                    .Title("Y")
                    .MinorTickSteps(1)
                    .Minimum(0)
                    .GridConfig(X.AxisGrid()
                        .Odd(new SpriteAttributes { Opacity = 1, Fill = "#ddd", Stroke = "#bbb", StrokeWidth = 0.5 })
                    ),
                X.CategoryAxis()
                    .Position(Position.Bottom)
                    .Fields("X")
                    .Title("X")
            )
            .Series(
                X.LineSeries()
                    .Axis(Position.Left)
                    .XField("X")
                    .YField("Y1")
                    .HighlightConfig(new SpriteAttributes { Size = 7, Radius = 7 })
                    .MarkerConfig(new SpriteAttributes { Type = SpriteType.Cross, Size = 4, Radius = 4, StrokeWidth = 0 })
            )
        )
    )
</body>
</html>
ChartController

public class ChartData
        {
            public int Cluster { get; set; }
            public int X { get; set; }
            public int Y { get; set; }
        }

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

 public DirectResult ReloadData()
        {
            var pnlChart = this.GetCmp<Panel>("pnlChart");
            var chtKpi = this.GetCmp<Chart>("chtKpi");

            int nClusters = 0;

            //Get random cluster with random number of points
            var data = GenerateData(ref nClusters);
            
            FixChart(chtKpi, nClusters);
            
            //NULL
            chtKpi.GetStore().Data = data;
            
            chtKpi.GetStore().DataBind();
            chtKpi.Update();           
           
            return this.Direct();
        }

private List<ExpandoObject> GenerateData(ref int nClusters)
        {
            var r = new Random();

            nClusters = r.Next(1, 10);
            
            var data = new List<ChartData>();

            Enumerable.Range(1, nClusters).ToList().ForEach(i => Enumerable.Range(1, r.Next(1, 10)).ToList().ForEach(j => data.Add(new ChartData { Cluster = i, X = r.Next(0, 100), Y = r.Next(0, 100) })));          
            
            var xGroup = data.GroupBy(i => i.X).Select(g => new { g.Key, Items = g.ToList() }).OrderBy(i => i.Key);

            var clusters = data.Select(i => i.Cluster).Distinct().OrderBy(i => i);

            //Get list of dynamic objects with dynamic fields (Y1, Y2, Y3, ...)
            var lst = new List<ExpandoObject>();

            foreach (var group in xGroup)
            {
                var obj = new ExpandoObject() as IDictionary<string, Object>;
                obj.Add("X", group.Key);

                foreach (var cluster in clusters)
                {
                    var y = group.Items.FirstOrDefault(c => c.Cluster == cluster && c.X == group.Key);
                    obj.Add("Y" + cluster.ToString(), y == null ? 0 : y.Y);
                }
                lst.Add((ExpandoObject)obj);
            }

            return lst;
        }

 private void FixChart(Chart chart, int nClusters)
        {
            //Fix model, axes and series based on dynamic data (# of clusters)

            var model = chart.GetStore().Model[0];
            var range = Enumerable.Range(1, nClusters).Select(i => String.Format("Y{0}", i)).ToList();

            //< ext:ModelField Name = "Y1" />
            range.ForEach(i =>
            {
                if (model.Fields.FirstOrDefault(f => f.Name == i) == null)
                    model.Fields.Add(i);
            });


            //< ext:NumericAxis Fields = "Y1, Y2, ..."
            var nax = (NumericAxis)chart.Axes.FirstOrDefault(a => a is NumericAxis);
            if (nax != null)
                nax.Fields = range.ToArray();

            range.ForEach(i =>
            {
                //< ext:LineSeries Axis = "Left" Smooth = "3" XField = "X" YField = "Y2" >       
                //   < HighlightConfig Size = "7" Radius = "7" />          
                //   < MarkerConfig Type = "Circle" Size = "4" Radius = "4" StrokeWidth = "0" />                 
                //</ ext:LineSeries >

                if ((LineSeries)chart.Series.FirstOrDefault(s => s is LineSeries && s.YField[0] == i) == null)
                    chart.Series.Add(
                            new LineSeries
                            {
                              Axis = Position.Left,
                              Smooth = 3,
                              XField = new[] { "X" },
                              YField = new[] { i },
                              HighlightConfig = new SpriteAttributes { Size = 7, Radius = 7 },
                              MarkerConfig = new SpriteAttributes { Type = SpriteType.Circle, Size = 4, Radius = 4, StrokeWidth = 0 }
                            });               
            });


        }