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. Image for the cookie policy date
close icon

Object to the column.

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 ?

3 Replies

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team August 28, 2017 01:00 PM UTC

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 




NO noName August 28, 2017 08:17 PM UTC

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.


FS Farveen Sulthana Thameeztheen Basha Syncfusion Team August 29, 2017 05:05 PM UTC

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 


Loader.
Live Chat Icon For mobile
Up arrow icon