PDA

View Full Version : [CLOSED] MVC Dynamic Buffered Store



baruch.gabo
Aug 10, 2014, 3:36 PM
I've been trying to create a dynamic (generated at run time) store that is buffered. However, when buffering is enabled the grid shows no rows or columns.
I'm able to reproduce the issue with the EXT MVC Infinite Scrolling Overview sample (http://mvc.ext.net/#/GridPanel_Infinite_Scrolling/Overview/).
By changing the Index.cshtml to:


@model System.Collections.IEnumerable
@{
ViewBag.Title = "Infinite Scrolling - Ext.NET MVC Examples";
Layout = "~/Views/Shared/_BaseLayout.cshtml";
}
@section example
{
<h1>Infinite Scrolling</h1>
<p>Ext.Net 2's brand new grid supports infinite scrolling, which enables you to load any number of records into a grid without paging.</p>
<p>The new grid uses a virtualized scrolling system to handle potentially infinite data sets without any impact on client side performance.</p>
@(Html.X().GridPanel()
.Width(500)
.Height(500)
.DisableSelection(true)
.Title("Stock Price")
.ID("grd")
.Store(Html.X().Store().ID("str")
.Buffered(true)
.PageSize(100)
.LeadingBufferZone(300)
.Model(Html.X().Model()
)
.Proxy(Html.X().AjaxProxy()
.Url(Url.Action("GetStockQuotations"))
.Reader(Html.X().JsonReader().Root("data"))
)
)
.ColumnModel(
)
.View(Html.X().GridView().TrackOver(false))
)
}


and the OverviewController Index code to:

public ActionResult Index()
{
var g = this.GetCmp<Ext.Net.GridPanel>("grd");
var s = this.GetCmp<Store>("str");
s.Fields.Clear();
g.ColumnModel.Columns.Clear();
s.AddField(new ModelField("Company"));
s.AddField(new ModelField("Price"));
s.AddField(new ModelField("LastUpdate"));
g.AddColumn(new RowNumbererColumn { Width = 50 });
g.AddColumn(new Column { Text = "Company", DataIndex = "Company", Flex = 1 });
g.AddColumn(new Column { Text = "Price, $", DataIndex = "Price", Width = 70, Align = Alignment.Center });
g.AddColumn(new Column { Text = "Last Update", DataIndex = "LastUpdate", Width = 140, Renderer = new Renderer() { Format = RendererFormat.Date, FormatArgs = new string[] { "'n/j/Y g:i:s A'" } } });
return View();
}

If you comment out the .Buffered(true) from the store markup the first rows will be loaded.
Can a dynamic store and grid be buffered?

Daniil
Aug 11, 2014, 7:06 AM
Hi @baruch.gabo,

Those methods - AddField, AddColumn - are supposed to be used during DirectEvents/DirectMethods only.

You should configure a View in a bit different way. For example, using a ViewBag object.

View

@(Html.X().GridPanel()
.Width(500)
.Height(500)
.DisableSelection(true)
.Title("Stock Price")
.ID("grd")
.Store(Html.X().Store().ID("str")
.Buffered(true)
.PageSize(100)
.LeadingBufferZone(300)
.Model(Html.X().Model().Fields(ViewBag.ModelFields ))
.Proxy(Html.X().AjaxProxy()
.Url(Url.Action("GetStockQuotations"))
.Reader(Html.X().JsonReader().Root("data"))
)
)
.ColumnModel(ViewBag.Columns)
.View(Html.X().GridView().TrackOver(false))
)

Controller

public ActionResult Index()
{
ModelField[] modelFields = new ModelField[]
{
new ModelField("Company"),
new ModelField("Price"),
new ModelField("LastUpdate")
};

ColumnBase[] columns = new ColumnBase[]
{
new RowNumbererColumn { Width = 50 },
new Column { Text = "Company", DataIndex = "Company", Flex = 1 },
new Column { Text = "Price, $", DataIndex = "Price", Width = 70, Align = Alignment.Center },
new Column { Text = "Last Update", DataIndex = "LastUpdate", Width = 140, Renderer = new Renderer() { Format = RendererFormat.Date, FormatArgs = new string[] { "'n/j/Y g:i:s A'" } } }
};

ViewBag.ModelFields = modelFields;
ViewBag.Columns = columns;

return View();
}

baruch.gabo
Aug 11, 2014, 6:28 PM
That was it. Thanks. You can mark it as closed