[CLOSED] MVC Dynamic Buffered Store

  1. #1

    [CLOSED] MVC Dynamic Buffered Store

    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.
    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?
    Last edited by Daniil; Aug 12, 2014 at 5:57 AM. Reason: [CLOSED]
  2. #2
    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();
    }
  3. #3
    That was it. Thanks. You can mark it as closed

Similar Threads

  1. Replies: 5
    Last Post: Apr 27, 2016, 12:43 AM
  2. [CLOSED] store config Buffered Example site?
    By qtec in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 20, 2014, 6:12 AM
  3. [CLOSED] Buffered store not loading all records
    By RCM in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 13, 2014, 6:09 AM
  4. [CLOSED] CheckColumn with buffered store
    By Leonid_Veriga in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 01, 2013, 12:02 PM
  5. [CLOSED] RemoteSort for buffered store
    By gets_gui in forum 2.x Legacy Premium Help
    Replies: 46
    Last Post: May 27, 2012, 8:02 PM

Tags for this Thread

Posting Permissions