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.

ITyped List Binding

Thread ID:

Created:

Updated:

Platform:

Replies:

116944 Jul 7,2014 03:12 PM Jul 8,2014 05:50 PM ASP.NET MVC 3
loading
Tags: Grid
Ross Macintyre
Asked On July 7, 2014 03:12 PM

Hi

I am looking at upgrading some of my projects to v12.1 and was wondering if the Grid javascript supports ITyped list binding like as the asp.net classic version?

When I tried just now, I get an error "Cannot convert lambda expression to type 'System.Collections.Generic.List<Syncfusion.JavaScript.Models.Column<object>>' because it is not a delegate type", so before looking further into, thought it would be better to ask.

If you, would be great if you could provide an example

Ross


Madhu Sudhanan P [Syncfusion]
Replied On July 8, 2014 08:30 AM

Hi Ross,

 

Thanks for using Syncfusion products.

 

We can populate the MVC Grid control with the ITyped List data. We can provide the ITypedList datasource to the grid as follow.

 

[ITypedList Class]

[Serializable()]

    public class SortableBindingList<T> : BindingList<T>, ITypedList

    {

 . .. . .

}

 

[DataContext Class]

public class StudentDetailsDataContext

    {

        public SortableBindingList<Student> GetStudent

        {

            get

            {

 

                int code = 10000;

                var data = new SortableBindingList<Student> { };

                for (long i = 0; i < 1000; i++)

                {

                    Student[] s = new Student[10];

                    s[0] = new Student() { UniversityCode = code + 1, CourseFees = 2000.00, CGPA = 7.52, Duration = 90, Title = "Distributed Component Architecture" };

                    s[1] = new Student() { UniversityCode = code + 2, CourseFees = 1000.00, CGPA = 9.55, Duration = 60, Title = "Data Structures" };

                    . . . . . .

                    s[9] = new Student() { UniversityCode = code + 10, CourseFees = 1500.00, CGPA = 8.66, Duration = 75, Title = "Design Patterns" };

                    foreach (Student studnt in s)

                    {

                        data.Add(studnt);

                    }

 

                    code += 10;

                }

                return data;

            }

        }

    }

 

[controller]

 

public ActionResult Index()

        {

            ViewData["data"] = new StudentDetailsDataContext().GetStudent.ToList(); //Getting the ITypedList data

            return View();

        }

 

[cshtml]

 

@(Html.EJ().Grid<object>("Grid")

.Datasource((IEnumerable<object>)ViewData["data"])  //Providing the data as IEnumerable to the grid

 . . . .

.AllowPaging()

.Render())

 

 

For your convenience we have also created the simple MVC grid sample in which the grid is populated with the ITypedList data and the same can be downloaded from the below location.

 

Sample Location: ITypedListBinding.zip

 

Please let us know if we misunderstood your requirement and provide us clear information(platform information ASP.Net or ASP.Net MVC) regarding your requirement. The information provided would be more helpful for us to analyze the requirement and provide you the response as early as possible.

 

Regards,

Madhu Sudhanan. P


Ross Macintyre
Replied On July 8, 2014 09:36 AM

Perfect, thanks for your reply.

Ross


Madhu Sudhanan P [Syncfusion]
Replied On July 8, 2014 05:50 PM

Hi Ross,

 

Thanks for your update. Please get back to us if you require further assistance, we will be happy to help you out.

 

Regards,

Madhu Sudhanan. P


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.

;