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.

composite property databinding

Thread ID:

Created:

Updated:

Platform:

Replies:

118029 Jan 22,2015 02:17 AM Jan 27,2015 07:49 AM ASP.NET MVC 3
loading
Tags: Grid
SP
Asked On January 22, 2015 02:17 AM

Hello Syncfusion team,

How do I implement data binding with composite datasource in Syncfusion MVC 12.4.0.24.



Balaji Marimuthu [Syncfusion]
Replied On January 23, 2015 09:20 AM

Hi Shane,

Thanks for using Syncfusion Products.

We have analyzed and achieved your requirement by using composite data source in the ejGrid. We have suggest you to use LINQ joint query to join two or more tables. Please find the below code snippet.

public static IList<ComplexGridViewModel> GetAllRecords()

        {

            using (var context = new NorthwindDataContext())

               

                return (from cust in context.Customers

                        join ord in context.Orders on cust.CustomerID equals ord.CustomerID

                        select new ComplexGridViewModel

                        {

                            OrderID = ord.OrderID,

                            OrderDate = ord.OrderDate,

                            EmployeeID = ord.EmployeeID,

                            Freight = ord.Freight,

                            CustomerID = cust.CustomerID,

                            Address = cust.Address,

                            City = cust.City,

                            Country = cust.Country

                        }).Take(20).ToList();

        }

    }

Please find the sample for your reference.

http://www.syncfusion.com/downloads/support/directtrac/118029/Databinding1977234846.zip

Please let us know if you have any queries.

Regards,

Balaji Marimuthu



SP
Replied On January 24, 2015 12:23 PM

Hello Balaji Marimuthu,

What if I have a customer who has a list of orders and I want to display all the order names with commas(or links to orders) in one column using a column template.

Thanks.


Balaji Marimuthu [Syncfusion]
Replied On January 27, 2015 07:49 AM

Hi Shane,

We have analyzed and achieved your requirement by using column template. Please find the below code snippet.

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

        <ul style="list-style-type:none; display: inline-flex;">

            {{for Order}}

            <li> {{:color}}</li>

            {{/for}}

        </ul>

    </script>

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

        <ul style="list-style-type:none; display: inline-flex;">

            {{for Order}}

            <li> <a rel='nofollow' href="{{:color}}" >{{:color}}</a></li>

            {{/for}}

        </ul>

    </script>

<script type="text/javascript">

           

            $(function () {// Document is ready.

                $("#Grid").ejGrid({

                    dataSource: window.gridData,

                   

                    columns: [

                           { headerText: "customer", template: true, templateID: "#template", textAlign: "center", width: 300 },

                           { headerText: "Orders", template: true, templateID: "#template1", textAlign: "center", width: 300 },

                          

                   . . . . . . .

                   ],

                });

            });

        </script>

In column template, we have displayed the list of names with commas and links using jsrender. We have attached the sample for your reference.

http://www.syncfusion.com/downloads/support/directtrac/118029/column_template1703888290.zip

Please let us know if you have any queries.

Regards,

Balaji Marimuthu



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.

;