ServerMapping returning [object Object]

Page 1 of 2 12 LastLast
  1. #1

    ServerMapping returning [object Object]

    Hi,

    In the following statement, can you give an explanation as to what the bold items refer to?

    <ext:RecordField Name="Uom" ServerMapping="Uom.Code" IsComplex="true"/>
    In our application, we are using NHibernate as our ORM but when I run this code which I got from https://examples1.ext.net/#/GridPane...erver_Mapping/, the values are getting returned as [object Object]. I've checked and the data is getting passed back from the server without any problem as can be seen here .

    What am I doing wrong?

    TIA,

    David
    Last edited by Daniil; Jun 08, 2011 at 3:46 PM. Reason: Please use [CODE] tags
  2. #2
    Hi,

    Where do you see "[object Object]"?
  3. #3
    Hi Vladimir,

    The [object Object] appears in a GridPanel as shown here.

    David
  4. #4
    Hi,

    How do you expect it should looks? UoM is javascript object and toString methid gives "[object Object]"
    If you need custom representation then you have to create own renderer for the column
  5. #5
    Hi Vladimir,

    I want to pull out Uom.Code as shown in the code given previously. Now you seem to believe that using a custom renderer will resolve the issue. Can you provide me with more details i.e. sample code or tutorial?

    Regards,

    David
  6. #6
    Hi,

    If you want to have Code only in that field then remove IsComplex
  7. #7
    I have removed it and I still get the same "error". Also, I think it would be helpful if you can answer the questions in the OP and explain what the attributes refer to.

    It will help educate the users and create less work for you guys in the long run.

    David
  8. #8
    Hi,

    Please always provide simple test sample which demonstrates the issue. It will allow us to answer very quick
    ServerMapping is property contains server side path to extract data (it can be single name or several names are split by dot)

    The following sample demonstrates how to extract data with ServerMapping (in this case department name will be serialized only) and Renderer with IsComplex (in this case, whole department object will be serialized)
    <%@ 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)
        {
            var store = this.GridPanel1.GetStore();
            
            store.DataSource = Employee.GetAll();
            store.DataBind();
        }
    
        public class Employee
        {
            public int ID { get; set; }
            public string Name { get; set; }
            public string Surname { get; set; }
            public Department Department1 { get; set; }
            public Department Department2 { get; set; }
    
            public static List<Employee> GetAll()
            {
                return new List<Employee>
                {
                   new Employee
                   {
                       ID = 1,
                       Name = "Nancy",
                       Surname = "Davolio",
                       Department1 = Department.GetAll()[0],
                       Department2 = Department.GetAll()[0]
                   },
                   new Employee
                   {
                       ID = 2,
                       Name = "Andrew",
                       Surname = "Fuller",
                       Department1 = Department.GetAll()[2],
                       Department2 = 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 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>Server Mapping - Ext.NET Examples</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:GridPanel
                ID="GridPanel1"
                runat="server"
                EnableViewState="true" 
                AutoHeight="true" 
                Title="List" 
                Icon="Application">
                <Store>
                    <ext:Store runat="server">
                        <Reader>
                            <ext:JsonReader IDProperty="ID">
                                <Fields>
                                    <ext:RecordField Name="ID" Type="Int" />
                                    <ext:RecordField Name="Name" />
                                    <ext:RecordField Name="Surname" />
                                    <ext:RecordField Name="Department1" ServerMapping="Department1.Name" />
                                    <ext:RecordField Name="Department2" IsComplex="true" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">                
                    <Columns>
                        <ext:Column Header="ID" DataIndex="ID" />
                        <ext:Column Header="NAME" DataIndex="Name" />
                        <ext:Column Header="SURNAME" DataIndex="Surname" />
                        <ext:Column DataIndex="Department1" Header="Department" Width="240" />
                        <ext:Column DataIndex="Department2" Header="Department" Width="240">
                            <Renderer Handler="return value.Name;" />
                        </ext:Column>
                    </Columns>
                </ColumnModel>            
            </ext:GridPanel>
        </form>
    </body>
    </html>
  9. #9
    Hi Vladimir,

    I am aware of this code as I used it to develop my current applicaiton. I will try and struggle on because at the moment, our application is using NHibernate and that means that there are lots of classes and interfaces. So giving you example code is not so straighforward. I'll keep asking questions though to see where I might be going wrong.

    David
  10. #10
    Hi Vladimir,

    I still can't quite figure out what is going wrong. So here is some code:

    In my "Store" I've got:

    <Proxy>
    	<ext:HttpProxy Url="MyUrl" />
    </Proxy>
    
    <Reader>
    	<ext:JsonReader IDProperty="Id" Root="data" TotalProperty="total">
    		<Fields>
    			<ext:RecordField Name="Uom" ServerMapping="Uom.Code" IsComplex="true"/>

    In the "Columns" section, I've got:
    	 <ext:Column DataIndex="Uom" Header='<%# Html.StringResource("UoM") %>'
    						AutoDataBind="true" Hidden="false">
    I know that I've got the right data because when I put a breakpoint in my code, I get the right data as can be seen here

    What further details would you require to be able to assist?
    Last edited by DavidS; Jun 13, 2011 at 12:49 PM.
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Uncaught TypeError: Object #<Object> has no method '***'
    By Sevilay Tanış in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Mar 27, 2012, 4:44 PM
  2. Replies: 0
    Last Post: Oct 21, 2011, 3:04 AM
  3. Replies: 1
    Last Post: Sep 13, 2011, 5:19 PM
  4. Replies: 4
    Last Post: Apr 12, 2010, 1:01 PM
  5. Replies: 0
    Last Post: Apr 14, 2009, 12:33 PM

Tags for this Thread

Posting Permissions