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.

Request for code for Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

128134 Jan 4,2017 07:28 AM Jan 5,2017 07:51 AM ASP.NET MVC 1
loading
Tags: Grid
ashwan
Asked On January 4, 2017 07:28 AM

I am  binding data coming as list not showing in grid ?
How can I bind the data in form of list coming from controller in grid ?

I need code for this in view and controller.

Ramdhas  Ueikattan [Syncfusion]
Replied On January 5, 2017 07:51 AM

Hi Ashwan, 

Thanks for contacting Syncfusion Supports. 


We have created a sample based on your requirement . please find the code example. 

@(Html.EJ().Grid<object>("Grid") 
                .Datasource((IEnumerable<object>)ViewBag.datasource) 
                .AllowPaging() 
                .Columns(col => 
                { 
                    col.Field("OrderID").HeaderText("OrderID").TextAlign(TextAlign.Right).Width(90).Add(); 
                    col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(90).Add(); 
                    col.Field("CustomerID").HeaderText("Customer ID").Width(100).Add(); 
                    col.Field("Freight").HeaderText("Freight").Format("{0:c2}").TextAlign(TextAlign.Right).Width(80).Add(); 
                     
                    
                }) 
            ) 
 
[controller]    
 
  public ActionResult Index(){ 
            var Data = GetData(); 
            ViewBag.dataSource = Data; 
            return View(); 
        } 
        public static List<Details> GetData() 
        { 
 
             List<Details> jsons = new List<Details>(); 
              
             int code = 1000; 
             for (int i = 1; i <= code; i++ ){ 
              jsons.Add(new Details(){ OrderID = code +i, EmployeeID =i, CustomerID= "ALAKI", Freight = code * 0.23}); 
                 jsons.Add(new Details(){ OrderID = code +i+1, EmployeeID =i, CustomerID= "VINET", Freight = code * 0.56}); 
                 jsons.Add(new Details() { OrderID = code +i+2 , EmployeeID = i, CustomerID = "TOMSP", Freight = code * 0.11 }); 
                 jsons.Add(new Details() { OrderID = code + i+3, EmployeeID = i, CustomerID = "VICTE", Freight = code * 0.44 }); 
                 i = i+4 ; 
             } 
             return jsons; 
                  
 
        } 
 
    public class Details { 
        public int OrderID { get; set; } 
        public int EmployeeID { get; set; } 
        public string CustomerID { get; set; } 
        public double Freight { get; set; } 
     
    } 
} 
 
 

For your convenience please find the sample . 





Thanks & Regards, 
Ramdhas U 


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.

;