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

ITyped List Binding

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


3 Replies

MS Madhu Sudhanan P Syncfusion Team July 8, 2014 12:30 PM UTC

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



RM Ross Macintyre July 8, 2014 01:36 PM UTC

Perfect, thanks for your reply.

Ross



MS Madhu Sudhanan P Syncfusion Team July 8, 2014 09:50 PM UTC

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


Loader.
Live Chat Icon For mobile
Up arrow icon