We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Object to the column.

Thread ID:

Created:

Updated:

Platform:

Replies:

132332 Aug 26,2017 03:12 PM Aug 29,2017 01:05 PM ASP.NET Core 3
loading
Tags: Grid
noName
Asked On August 26, 2017 03:12 PM

I have this grid:

<ej-grid id="FlatGrid" allow-sorting="true" allow-paging="true" show-summary="true">
                <e-datamanager json="ViewBag.dataSource" offline="true" cross-domain="true"></e-datamanager>
                <e-toolbar-settings show-toolbar="true" toolbar-items=@(new List<string>() {"excelExport","wordExport","pdfExport" })>

                </e-toolbar-settings>

                <e-columns>
                    <e-column field="Name" header-text="Name" width="75"></e-column>
                    <e-column field="Cities" header-text="Cities" width="75"></e-column>
                    </e-column>
                </e-columns>
            </ej-grid>

The problem is that every object has Cities as another object with city names. How can I display all of them for current user in the column cell Cities ?

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On August 28, 2017 09:00 AM

Hi Customer, 

Thanks for contacting Syncfusion Support. 

We need some additional information to achieve your requirement. Could you please share us the following details given below. 

1.  Screenshot/ Video about your requirement that how you want to display the Grid. 

2. Do you want to display the Grid column as in the form of Relational Binding. 

3. Elaborate your requirement. 

The provided information will help us to analyze and provide you the solution as early as possible. 

Regards, 

Farveen sulthana T 



noName
Replied On August 28, 2017 04:17 PM

I am following the answer from here:

https://www.syncfusion.com/kb/2465/how-to-display-array-of-strings-within-a-grid-column

, but trying to implement it for Core MVC:

<script type="text/x-jsrender" id="InterestsTemplate">

                {{:~getVal(Cities,"name")}}

            </script>

            <ej-grid id="FlatGrid" datasource="ViewBag.DataSource">

                <e-columns>

                    <e-column field="Name" header-text="Name"></e-column>

                    <e-column header-text="Cities" Template=true TemplateID="CitiesTemplate"></e-column>

                </e-columns>

            </ej-grid>

Data looks like  this:

[{"name":"Name 1","cities":[{"name":"City 1"},{"name":"City2"},{"name":"City3"}]}]
or 1 row from table can have alot of cities, which I want to put to its cell.

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On August 29, 2017 01:05 PM

Hi Customer, 
  
We have checked your issue and bound the list of strings within a colum according to the KB. But we are unable to reproduce your reported problem at our end. Please refer to the code example:- 
  
<ej-grid id="FlatGrid" allow-paging="true" >  
    <e-datamanager url="/Home/DataSource" adaptor="UrlAdaptor"/>  
    <e-columns>  
        <e-column field="ID" header-text=ID" is-primary-key="true"width="75"></e-column>  
        <e-column field="FirstName " header-text="First Name"></e-column>  
             <e-column field="LastName " header-text="Last Name"></e-column> 
        <e-column field="Address " header-text="Address" template="true" template-id="#template" ></e-column> 
    </e-columns>  
</ej-grid>  
     <script type="text/x-jsrender" id ="template"> 
         {{for Addresses}} 
            <span>{{>Address1}}</span>  
            <span>{{>Address2}}</span><br /> 
         {{/for}} 
     </script> 
  
Serverside:- 
  
         List<Person> Persons = new List<Person>(); 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            BindDataSource(); 
        } 
        private void BindDataSource() 
        { 
  
            List<Address> adrs1 = new List<Address>(); 
            adrs1.Add(new Address() { Address1 = "No: 417", Address2 = "1st street", City = "Aurora", Country = "Arapahoe", Zip = "80010" }); 
            . . . 
            List<Address> adrs2 = new List<Address>(); 
            adrs2.Add(new Address() { Address1 = "No: 378", Address2 = "3rd cross street", City = "Austin", Country = "Travis", Zip = "78701" }); 
            .  .  . 
            List<Address> adrs3 = new List<Address>(); 
            adrs3.Add(new Address() { Address1 = "No: 195", Address2 = "7th golden street", City = "Sandy", Country = "Salt Lake", Zip = "84070" }); 
             
            Persons.Add(new Person() { ID = 1001, FirstName = "John", LastName = "Beckett", Addresses = adrs1 }); 
            Persons.Add(new Person() { ID = 1002, FirstName = "Ben", LastName = "Smith", Addresses = adrs2 }); 
            Persons.Add(new Person() { ID = 1003, FirstName = "Andrew", LastName = "Fuller", Addresses = adrs3 }); 
  
            this.Grid.DataSource = Persons; 
            this.Grid.DataBind(); 
        } 
  
        [Serializable] 
        public class Person 
        { 
            public Person() 
            { 
  
            } 
            public Person(int id, string firstName, string lastName, List<Address> address) 
            { 
                this.ID = id; 
                this.FirstName = firstName; 
                this.LastName = lastName; 
                this.Addresses = address; 
            } 
            public int ID { get; set; } 
            public string FirstName { get; set; } 
            public string LastName { get; set; } 
            public List<Address> Addresses { get; set; } 
        } 
        [Serializable] 
        public class Address 
        { 
            public string Address1 { get; set; } 
            public string Address2 { get; set; } 
            public string City { get; set; } 
            public string Country { get; set; } 
            public string Zip { get; set; } 
        } 
    } 
  
After following the above solution, still facing the same problem could you please share us the following details with us given below. 
  
1.Complete Grid Code example(both in server and client side) 
  
2. Screenshot/Video to replicate the issue. 
  
3. If possible, provide an issue reproducing sample or hosted link.  
  
4. Essential studio product version details. 
  
The provided information will help us to analyze and provide you the solution as early as possible. 
  
Regards, 
  
Farveen sulthana T 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;