http://examples.ext.net/#/GridPanel/Data_Presentation/Editor_Field_Mapping/

  1. #1

    http://examples.ext.net/#/GridPanel/Data_Presentation/Editor_Field_Mapping/

    I have used examples https://examples2.ext.net/#/GridPane...Field_Mapping/ in my project but it doesn't work. The code is given below.

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            this.StoreCombo.DataSource = Department.GetAll();
            this.StoreCombo.DataBind();
    
            this.Store1.DataSource = Employee.GetAll();
            this.Store1.DataBind();
        }
    
        public class Employee
        {
            public int ID { get; set; }
            public string Name { get; set; }
            public string Surname { get; set; }
            public Department Department { get; set; }
    
            public int DepartmentId
            {
                get { return this.Department != null ? this.Department.ID : -1; }
            }
    
            public static List<Employee> GetAll()
            {
                return new List<Employee>
                           {
                               new Employee
                                   {
                                       ID = 1,
                                       Name = "Nancy",
                                       Surname = "Davolio",
                                       Department = Department.GetAll()[0]
                                   },
                               new Employee
                                   {
                                       ID = 2,
                                       Name = "Andrew",
                                       Surname = "Fuller",
                                       Department = Department.GetAll()[2]
                                   }
                           };
            }
        }
    
        public class Department
        {
            public int ID { get; set; }
            public string Name { get; set; }
    
            public static List<Department> GetAll()
            {
                return new List<Department>
                           {
                               new Department {ID = 1, Name = "Department A"},
                               new Department {ID = 2, Name = "Department B"},
                               new Department {ID = 3, Name = "Department C"}
                           };
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Editor Field Mapping - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
    
        <script>
            var departmentRenderer = function (value) {
                var r = App.StoreCombo.getById(value);
    
                if (Ext.isEmpty(r)) {
                    return "";
                }
    
                return r.data.Name;
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Store ID="StoreCombo" runat="server">
                <Model>
                    <ext:Model runat="server" IDProperty="ID">
                        <Fields>
                            <ext:ModelField Name="ID" />
                            <ext:ModelField Name="Name" />
                        </Fields>
                    </ext:Model>
                </Model>
            </ext:Store>
            
            <ext:GridPanel 
                Height="100"
                runat="server"
                Title="List" 
                Icon="Application">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Model>
                            <ext:Model runat="server" IDProperty="ID">
                                <Fields>
                                    <ext:ModelField Name="ID" Type="Int" />
                                    <ext:ModelField Name="Name" />
                                    <ext:ModelField Name="Surname" />
                                    <ext:ModelField Name="DepartmentId" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="ID" DataIndex="ID" />
                        <ext:Column runat="server" Text="NAME" DataIndex="Name" />
                        <ext:Column runat="server" Text="SURNAME" DataIndex="Surname" />
                        <ext:Column runat="server" Text="DEPARTMENT" DataIndex="DepartmentId" Width="240">
                            <Renderer Fn="departmentRenderer" />
                            <Editor>
                                <ext:ComboBox 
                                    runat="server"     
                                    QueryMode="Local"   
                                    Editable="false"                     
                                    StoreID="StoreCombo" 
                                    DisplayField="Name" 
                                    ValueField="ID"
                                    />
                            </Editor> 
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <Plugins>
                    <ext:CellEditing runat="server" />
                </Plugins>
            </ext:GridPanel>
        </form>
    </body>
    </html>
    But it hangs on following code
    -----------------------------------------------------
    var departmentRenderer = function (value) {
                var r = App.StoreCombo.getById(value);
    
                if (Ext.isEmpty(r)) {
                    return "";
                }
    
                return r.data.Name;
            };
    -------------------------------------------------------------------

    Issue with this statement
    var r = App.StoreCombo.getById(value);
    can not find method getById(value) of StoreCombo anywhere in code.

    Plz give me solution for that.

    Otherwise give me other example that uses grid panel with editor as combox with displayfied and valuefield property and binds using Store.

    Any help will be realy apprecited.

    Thanks
    Last edited by Daniil; Jan 02, 2013 at 6:59 AM. Reason: Please use [CODE] tags
  2. #2
    Hi @shaileshsakaria,

    Welcome to Ext.NET forums!

    The online example appears to be working fine.

    Please clarify what Ext.NET version do you use?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @shaileshsakaria,

    Welcome to Ext.NET forums!

    The online example appears to be working fine.

    Please clarify what Ext.NET version do you use?

    I am using Ext.net version 2.1
  4. #4
    Ok. Please demonstrate the Web.config.
  5. #5
    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        <section name="extnet" type="Ext.Net.GlobalConfig" requirePermission="false" />
      </configSections>
      <extnet scriptMode="Debug" theme="Gray" />
      <connectionStrings>
        <add name="TACCEntities" connectionString="metadata=res://*/TACC.csdl|res://*/TACC.ssdl|res://*/TACC.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=shailesh;initial catalog=TTDesign;persist security info=True;user id=sa;password=mypassword;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
        <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-TTDesign.UI-20130101172144;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-TTDesign.UI-20130101172144.mdf" />
      </connectionStrings>
      <system.web>
        <compilation debug="true" targetFramework="4.5" >
          <expressionBuilders>
            <add expressionPrefix="Code" type="TTDesign.UI.StaticMethod.CodeExpressionBuilder" />
          </expressionBuilders>
        </compilation>
        <httpRuntime targetFramework="4.5" />
    
        <httpHandlers>
          <add path="*/ext.axd" verb="*" type="Ext.Net.ResourceHandler" validate="false" />
        </httpHandlers>
        <httpModules>
          <add name="DirectRequestModule" type="Ext.Net.DirectRequestModule, Ext.Net" />
        </httpModules>
    
        <pages>
          <namespaces>
            <add namespace="System.Web.Optimization" />
            <add namespace="Ext.Net"/>
          </namespaces>
          <controls>
            <add assembly="Ext.Net" namespace="Ext.Net" tagPrefix="ext" />
            <add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
          </controls>
        </pages>
        <authentication mode="Forms">
          <forms loginUrl="~/Default.aspx" timeout="2880" />
        </authentication>
        <profile defaultProvider="DefaultProfileProvider">
          <providers>
            <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
          </providers>
        </profile>
        <membership defaultProvider="DefaultMembershipProvider">
          <providers>
            <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
          </providers>
        </membership>
        <roleManager defaultProvider="DefaultRoleProvider">
          <providers>
            <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
          </providers>
        </roleManager>
        <!--
                If you are deploying to a cloud environment that has multiple web server instances,
                you should change session state mode from "InProc" to "Custom". In addition,
                change the connection string named "DefaultConnection" to connect to an instance
                of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
          -->
        <sessionState mode="InProc" customProvider="DefaultSessionProvider">
          <providers>
            <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
          </providers>
        </sessionState>
      </system.web>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules>
          <add
                    name="DirectRequestModule"
                    preCondition="managedHandler"
                    type="Ext.Net.DirectRequestModule, Ext.Net"
                    />
        </modules>
        <handlers>
          <add
                    name="DirectRequestHandler"
                    verb="*"
                    path="*/ext.axd"
                    preCondition="integratedMode"
                    type="Ext.Net.ResourceHandler"
                    />
        </handlers>
      </system.webServer>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
            <bindingRedirect oldVersion="1.0.0.0-4.5.9" newVersion="4.5.10" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Ext.Net.Utilities" publicKeyToken="2c34ac34702a3c23" />
            <bindingRedirect oldVersion="0.0.0.0-2.0.1" newVersion="2.1.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Transformer.NET" publicKeyToken="e274d618e7c603a7" />
            <bindingRedirect oldVersion="0.0.0.0-2.0.0" newVersion="2.1.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="v11.0" />
          </parameters>
        </defaultConnectionFactory>
      </entityFramework>
    </configuration>
    Last edited by Daniil; Jan 02, 2013 at 8:08 AM. Reason: Please use [CODE] tags
  6. #6
    Thank you.

    I just tested the example with the 2.1.1 release and your Web.config. It works fine for me and doesn't throw any errors.
  7. #7
    Thanks for your timely support.

    I got the solution. Actually I was using master page so I have written
    App.MainContent_StoreCombo.getById(value);
    --Here MainContent is my master page content

    instead of this
    App.StoreCombo.getById(value);
    Thanks a lot
    Last edited by Daniil; Jan 02, 2013 at 9:11 AM. Reason: Please use [CODE] tags

Similar Threads

  1. Replies: 2
    Last Post: Jun 24, 2011, 5:33 PM
  2. [CLOSED] http://examples.ext.net/#/Toolbar/StatusBar/Overview/ Character count
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 12, 2011, 4:41 PM
  3. Replies: 2
    Last Post: Feb 18, 2011, 10:27 AM
  4. http://examples.ext.net/ can not be accessed!
    By Santon_Lee in forum 1.x Help
    Replies: 1
    Last Post: Nov 04, 2010, 4:34 AM
  5. more error in http://examples.ext.net
    By maxdiable in forum 1.x Help
    Replies: 0
    Last Post: Jun 11, 2010, 5:21 PM

Posting Permissions