[CLOSED] PartialViewResult and Store refresh

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] PartialViewResult and Store refresh

    I have a problem refreshig the store. Trying that I receive always an ID not found error...

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BPM.MVC.Web.ViewData.QuotationViewData>" %>
    <script runat="server">
        protected void QuotationStore_RefreshData(object sender, StoreRefreshDataEventArgs e)
        {
            this.QuotationGridPanel.Store.Primary.DataSource = this.Model.QuotationList;
            this.QuotationGridPanel.Store.Primary.DataBind();
        }
    </script>
    <ext:FitLayout runat="server">
        <Items>
            <ext:GridPanel 
                ID="QuotationGridPanel"
                runat="server" 
                Icon="Table"
                Frame="false">
                <Store>
                    <ext:Store 
                        runat="server" 
                        AutoDataBind="true" 
                        AutoLoad="true" 
                        DataSource="<%# Model.QuotationList %>" 
                        OnRefreshData="QuotationStore_RefreshData">
                        <Reader>
                            <ext:JsonReader IDProperty="ID">
                                <Fields>
                                    <ext:RecordField Name="ID" />
                                    <ext:RecordField Name="FirstName" />
                                    <ext:RecordField Name="LastName" />
                                    <ext:RecordField Name="ClubName" />
                                    <ext:RecordField Name="IndexNumber" />
                                    <ext:RecordField Name="HandicapIndex" />
                                    <ext:RecordField Name="rowversion" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column DataIndex="ID" Header="ID" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="FirstName" Header="FirstName" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="LastName" Header="LastName" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="ClubName" Header="ClubName" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="IndexNumber" Header="IndexNumber" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="HandicapIndex" Header="HandicapIndex" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="rowversion" Header="rowversion" Width="150" Sortable="true"/>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" />
                </SelectionModel>
                <View>
                    <ext:GridView runat="server" ForceFit="true" />
                </View>
                <LoadMask ShowMask="true" />
                <TopBar>
                    <ext:PagingToolbar runat="server" AutoDoLayout="true"/>
                </TopBar>
                <BottomBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:ToolbarFill runat="server" />
                            <ext:Button runat="server" Icon="PageExcel" ToolTip="XLS">
                                <Listeners>
                                    <Click Handler="getData(#{QuotationGridPanel}, #{FormatType}, 'xml');" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button runat="server" Icon="PageAttach" ToolTip="CSV">
                                <Listeners>
                                    <Click Handler="getData(#{QuotationGridPanel}, #{FormatType}, 'xml');" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button runat="server" Icon="PageCode" ToolTip="XML">
                                <Listeners>
                                    <Click Handler="getData(#{QuotationGridPanel}, #{FormatType}, 'xml');" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </BottomBar>
            </ext:GridPanel>
        </Items>
    </ext:FitLayout>
  2. #2

    RE: [CLOSED] PartialViewResult and Store refresh

    Hi,

    Do you render that View as partial view in the controller? If yes then you cannot use it because on next request (for example, when call 'reload') that view is not loaded to the memory on the server side therefore ASP.NET cannot find the store and OnRefreshData handler (ASP.NET doesn't maintane dynamic view between requests). You have to use another controller action to reload the store's data
    Vladimir Shcheglov
    Sr. Developer
  3. #3

    RE: [CLOSED] PartialViewResult and Store refresh

    Hi Vladimir,

    Does that mean I have to use a controller to bind a store to a model if i use custom-controls in conjunction with partialviewresult?

    Regards,
    Flavio
  4. #4

    RE: [CLOSED] PartialViewResult and Store refresh

    Hi,

    Yes, it is better to use separate controller action and bind data from the model
    Generally, MVC paradigm implies that view should not contains any logic. Binding data to the controls must be placed in the controller (data retrieving from DB must be placed in the Model)
    Vladimir Shcheglov
    Sr. Developer
  5. #5

    RE: [CLOSED] PartialViewResult and Store refresh



    Hi Vladimir,

    Actually my controller action looks like this:

            public ActionResult Index(string myContainerId)
            {
                QuotationViewData myQuotationViewData = ViewDataFactory.CreateBaseViewData<QuotationViewData>("Quotation List");
                myQuotationViewData.QuotationList = service.GetAll();
    
    
                Ext.Net.MVC.PartialViewResult myPartialViewResult = new Ext.Net.MVC.PartialViewResult();
                myPartialViewResult.ViewData.Model = myQuotationViewData;
                myPartialViewResult.ContainerId = myContainerId;
                myPartialViewResult.RenderMode = RenderMode.AddTo;
    
    
                return myPartialViewResult;
            }
    And the model passed to the view looks like this:

    namespace BPM.MVC.Web.ViewData
    {
        public class QuotationViewData : BaseViewData
        {
            public Quotation Quotation { get; set; }
            public List<Quotation> QuotationList { get; set; }
            public RoundDto RoundDto { get; set; }
        }
    }
    How I should proceed if I want to maintain the merged way (not iframe) to integrate my controls to the webapplication?

    Best regards,
    Flavio
  6. #6

    RE: [CLOSED] PartialViewResult and Store refresh

    Hi,

    Just you have to add HttpProxy to your store (instead OnRefreshData handler), HttpProxy must retrieve data from controller action


    1. Add Proxy
    <ext:HttpProxy Url="/Data/GetCustomers/" />

    2. Bind data in the controller action
     public AjaxStoreResult GetCustomers()
    {
          return new AjaxStoreResult(this.DBContext.Customers);
    }
    Vladimir Shcheglov
    Sr. Developer
  7. #7

    RE: [CLOSED] PartialViewResult and Store refresh



    Hi Vladimir

    I'm sorry but maybe I have tomatos on my eyes :-) it doesn't work....

    index.ascx

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BPM.MVC.Web.ViewData.QuotationViewData>" %>
    <ext:FitLayout runat="server">
        <Items>
            <ext:GridPanel 
                ID="QuotationGridPanel"
                runat="server" 
                Icon="Table"
                Frame="false">
                <Store>
                    <ext:Store runat="server">
                        <Proxy>
                            <ext:HttpProxy Url="/Quotation/QuotationList" />
                        </Proxy>
                        <Reader>
                            <ext:JsonReader Root="data" IDProperty="ID" TotalProperty="total">
                                <Fields>
                                    <ext:RecordField Name="ID" Type="String" />
                                    <ext:RecordField Name="FirstName" Type="String" />
                                    <ext:RecordField Name="LastName" Type="String" />
                                    <ext:RecordField Name="HandicapIndex" Type="Float" />
                                    <ext:RecordField Name="IsPlus" Type="Boolean" />
                                    <ext:RecordField Name="IndexNumber" Type="String" />
                                    <ext:RecordField Name="ClubName" Type="String" />
                                    <ext:RecordField Name="rowversion" Type="String" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>            
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column DataIndex="ID" Header="ID" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="FirstName" Header="FirstName" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="LastName" Header="LastName" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="HandicapIndex" Header="HandicapIndex" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="IsPlus" Header="IsPlus" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="IndexNumber" Header="IndexNumber" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="ClubName" Header="ClubName" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="rowversion" Header="rowversion" Width="150" Sortable="true"/>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" />
                </SelectionModel>
                <View>
                    <ext:GridView runat="server" ForceFit="true" />
                </View>
                <LoadMask ShowMask="true" />
                <TopBar>
                    <ext:PagingToolbar runat="server" AutoDoLayout="true" Selectable="true" EnableViewState="true"/>
                </TopBar>
                <BottomBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button runat="server" Icon="PageExcel" ToolTip="XLS">
                                <Listeners>
                                    <Click Handler="getData(#{QuotationGridPanel}, #{FormatType}, 'xml');" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button runat="server" Icon="PageAttach" ToolTip="CSV">
                                <Listeners>
                                    <Click Handler="getData(#{QuotationGridPanel}, #{FormatType}, 'xml');" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button runat="server" Icon="PageCode" ToolTip="XML">
                                <Listeners>
                                    <Click Handler="getData(#{QuotationGridPanel}, #{FormatType}, 'xml');" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </BottomBar>
            </ext:GridPanel>
        </Items>
    </ext:FitLayout>

    controller:
            public AjaxStoreResult QuotationList()
            {
                QuotationViewData myQuotationViewData = ViewDataFactory.CreateBaseViewData<QuotationViewData>("Quotation List");
                myQuotationViewData.QuotationList = service.GetAll();
    
    
                return new AjaxStoreResult(myQuotationViewData.QuotationList, myQuotationViewData.QuotationList.Count);
            }
    json (http://localhost:2146/quotation/quotationlist)
    {data:[{"ID":"0a0d384b-7fe9-46d8-8c4e-05e97b9f75a1","FirstName":"King","LastName":"Wilder","HandicapIndex":1.0,"IsPlus":true,"IndexNumber":"9233833","ClubName":"Brookside Golf Course","rowversion":"AAAAAAABnhg="},{"ID":"7dd8da2d-4e41-44b6-8d5b-5bfab74a72cc","FirstName":"Scratch","LastName":"Golfer","HandicapIndex":11.0,"IsPlus":true,"IndexNumber":"8337487","ClubName":"Pebble Beach Golf Links","rowversion":"AAAAAAABnhc="},{"ID":"8adfca43-da20-4a94-a900-663ea2b64789","FirstName":"Henry","LastName":"Wilson","HandicapIndex":1.0,"IsPlus":true,"IndexNumber":"3094847","ClubName":"Encino Golf Course","rowversion":"AAAAAAABnhY="},{"ID":"80df3100-cf70-4301-97e5-a434453d55e7","FirstName":"Sandy","LastName":"Bagger","HandicapIndex":1.0,"IsPlus":true,"IndexNumber":"2938471","ClubName":"Arcadia Golf Course","rowversion":"AAAAAAABnhU="}], total: 4}
    any ideas?










  8. #8

    RE: [CLOSED] PartialViewResult and Store refresh

    Hi,

    Please provide more details about 'it doesn't work....'
    Do you have any js errors or do you have empty grid? Many stores in the Ext.NET MVC application (http://code.google.com/p/extnet-mvc/) uses the proxy and all works fine
    Vladimir Shcheglov
    Sr. Developer
  9. #9

    RE: [CLOSED] PartialViewResult and Store refresh

    In firebug I see the following:


    <DIV aria-expanded=true class="errorTitle focusRow subLogRow " role=listitem>syntax error
    <DIV class="errorTrace " role=presentation>
    <DIV class="errorSourceBox errorSource-syntax focusRow subLogRow " role=listitem><A class="errorSource a11yFocus ">ndex:"ClubName",header:"ClubName",widt....addAnd DoLayout(ID_4ed41752a9754ea6bbd</A>
  10. #10

    RE: [CLOSED] PartialViewResult and Store refresh

    Hi,

    Please provide your test sample
    Here is my test case which works fine

    ViewPage
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        
        <ext:Panel ID="Panel1" runat="server" Width="600" Height="400" Title="Panel" Layout="Fit">    
            <AutoLoad Url="/Test/Grid">
                <Params>
                    <ext:Parameter Name="containerId" Value="#{Panel1}" Mode="Value" />
                </Params>
            </AutoLoad>
        </ext:Panel>
        
    </body>
    </html>
    PartialView
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <ext:FitLayout runat="server">
        <Items>
            <ext:GridPanel 
                ID="QuotationGridPanel"
                runat="server" 
                Icon="Table"
                Frame="false">
                <Store>
                    <ext:Store runat="server">
                        <Proxy>
                            <ext:HttpProxy Url="Test/GetData" />
                        </Proxy>
                        <Reader>
                            <ext:JsonReader Root="data" IDProperty="ID" TotalProperty="total">
                                <Fields>
                                    <ext:RecordField Name="ID" Type="String" />
                                    <ext:RecordField Name="FirstName" Type="String" />
                                    <ext:RecordField Name="LastName" Type="String" />
                                    <ext:RecordField Name="HandicapIndex" Type="Float" />
                                    <ext:RecordField Name="IsPlus" Type="Boolean" />
                                    <ext:RecordField Name="IndexNumber" Type="String" />
                                    <ext:RecordField Name="ClubName" Type="String" />
                                    <ext:RecordField Name="rowversion" Type="String" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                        <AutoLoadParams>
                            <ext:Parameter Name="start" Value="0" Mode="Raw" />
                            <ext:Parameter Name="limit" Value="20" Mode="Raw" />
                        </AutoLoadParams>
                    </ext:Store>            
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column DataIndex="ID" Header="ID" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="FirstName" Header="FirstName" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="LastName" Header="LastName" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="HandicapIndex" Header="HandicapIndex" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="IsPlus" Header="IsPlus" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="IndexNumber" Header="IndexNumber" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="ClubName" Header="ClubName" Width="150" Sortable="true"/>
                        <ext:Column DataIndex="rowversion" Header="rowversion" Width="150" Sortable="true"/>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" />
                </SelectionModel>
                <View>
                    <ext:GridView runat="server" ForceFit="true" />
                </View>
                <LoadMask ShowMask="true" />
                <TopBar>
                    <ext:PagingToolbar runat="server" AutoDoLayout="true" Selectable="true" EnableViewState="true"/>
                </TopBar>
                <BottomBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:Button runat="server" Icon="PageExcel" ToolTip="XLS">
                                <Listeners>
                                    <Click Handler="getData(#{QuotationGridPanel}, #{FormatType}, 'xml');" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button runat="server" Icon="PageAttach" ToolTip="CSV">
                                <Listeners>
                                    <Click Handler="getData(#{QuotationGridPanel}, #{FormatType}, 'xml');" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button runat="server" Icon="PageCode" ToolTip="XML">
                                <Listeners>
                                    <Click Handler="getData(#{QuotationGridPanel}, #{FormatType}, 'xml');" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </BottomBar>
            </ext:GridPanel>
        </Items>
    </ext:FitLayout>
    Controller
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Web.Mvc.Ajax;
    using Ext.Net;
    
    
    namespace Ext.Net.MVC.Demo.Controllers
    {
        public class TestController : Controller
        {
            public ActionResult Index()
            {
    
                return View();
            }
    
            public ActionResult Grid(string containerId)
            {
                Ext.Net.MVC.PartialViewResult myPartialViewResult = new Ext.Net.MVC.PartialViewResult();
                myPartialViewResult.ContainerId = containerId;
                myPartialViewResult.RenderMode = RenderMode.AddTo;
    
                return myPartialViewResult;
            }
    
            public AjaxStoreResult GetData(int start, int limit)
            {
                return new AjaxStoreResult(new List<object> {
                    new { ID = 1, FirstName="FirstName1", LastName="LastName1"},
                    new { ID = 2, FirstName="FirstName2", LastName="LastName2"},
                    new { ID = 3, FirstName="FirstName3", LastName="LastName3"},
                    new { ID = 4, FirstName="FirstName4", LastName="LastName4"},
                    new { ID = 5, FirstName="FirstName5", LastName="LastName5"}
                }, 5);
            }
        }
    }
    Vladimir Shcheglov
    Sr. Developer
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Refresh ComboBox after changing Store
    By ljcorreia in forum 1.x Premium Help
    Replies: 6
    Last Post: Sep 27, 2013, 3:42 PM
  2. [CLOSED] Refresh store from directmethod
    By krzak in forum 1.x Premium Help
    Replies: 6
    Last Post: Mar 10, 2011, 4:13 PM
  3. [CLOSED] Refresh store after AfterRecordUpdated event
    By methode in forum 1.x Premium Help
    Replies: 6
    Last Post: Nov 23, 2010, 4:25 PM
  4. [CLOSED] Refresh problem with PartialViewResult
    By Stefanaccio in forum 1.x Premium Help
    Replies: 4
    Last Post: Jul 02, 2010, 6:19 AM
  5. Refresh a Store
    By heysol in forum 1.x Help
    Replies: 3
    Last Post: Jan 07, 2009, 12:06 PM

Posting Permissions