[CLOSED] Ext.Net 2.1 Store's model with mappings

  1. #1

    [CLOSED] Ext.Net 2.1 Store's model with mappings

    Hello.

    I use source code form trunk brunch, revision 5229. I have store's model with mapping. For fields, which has mapping, data is not loading on client. Please see example below.

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected override void OnLoad(EventArgs e)
        {
            var test = new int[10];
            var rnd = new Random();
            var _i = 0;
            this.Store1.DataSource = test.Select(s => new
            {
                Id = ++_i,
                Id2 = _i,
                Name = "Name_" + rnd.Next(100),
                Name2 = "Name2_" + rnd.Next(100)
            });
            this.Store1.DataBind();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            <ext:GridPanel
                ID="GridPanel1"
                runat="server" 
                Title="Array Grid" 
                Width="700" 
                Height="310">
                <Store>
                    <ext:Store ID="Store1" runat="server" AutoLoad="true">
            <Model>
                <ext:Model ID="Model1" runat="server" IDProperty="Id">
                    <Fields>
                        <ext:ModelField Name="Id" Type="Int" />
                        <ext:ModelField Name="ID" Mapping="Id2" Type="Int" UseNull="true" />
                        <ext:ModelField Name="Name" />
                        <ext:ModelField Name="Test_Name2" Mapping="Name2" />
                        
                    </Fields>
                </ext:Model>
            </Model>
        </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:Column ID="Column1" runat="server" Text="ID" DataIndex="Id" Flex="1" />
                        <ext:Column ID="Column2" runat="server" Text="ID2" DataIndex="ID" Flex="1" />
                        <ext:Column ID="Column5" runat="server" Text="Name" DataIndex="Name" Flex="1" />
                        <ext:Column ID="Column6" runat="server" Text="Name2" DataIndex="Test_Name2" Flex="1" />
                    </Columns>
                </ColumnModel>                  
            </ext:GridPanel>
        </form>
    </body>
    </html>
    Could you, please, suggest a way to fix this issue?

    Best regards.
    Last edited by Daniil; Jul 04, 2013 at 8:13 AM. Reason: [CLOSED]
  2. #2
    Hi,

    You should use Data instead DataSource.
    this.Store1.Data = test.Select(s => new
    {
        Id = ++_i,
        Id2 = _i,
        Name = "Name_" + rnd.Next(100),
        Name2 = "Name2_" + rnd.Next(100)
    });
    Or use ServerMapping isntead of Mapping.
    <ext:ModelField Name="ID" ServerMapping="Id2" Type="Int" UseNull="true" />
    <ext:ModelField Name="Test_Name2" ServerMapping="Name2" />
  3. #3
    ServerMapping attribute works for me. Thank you.

Similar Threads

  1. [CLOSED] Store UpdateProxy with Model databind
    By softmachine2011 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 20, 2012, 12:40 PM
  2. RESTful MVC bind Model to Store
    By Dominik in forum 1.x Help
    Replies: 6
    Last Post: Nov 10, 2011, 2:34 PM
  3. [CLOSED] MVC, Binding model to Store
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 08, 2011, 3:19 PM
  4. ListFilter with mappings
    By syncos in forum Feature Requests
    Replies: 0
    Last Post: Dec 15, 2010, 1:57 PM
  5. ListFilter with mappings
    By syncos in forum 1.x Help
    Replies: 8
    Last Post: Dec 15, 2010, 1:40 PM

Posting Permissions