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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to bind JSON data to Grid using Javascript?

Thread ID:





123816 Apr 24,2016 10:35 AM UTC Apr 25,2016 11:38 AM UTC JavaScript 1
Tags: ejGrid
Asked On April 24, 2016 10:35 AM UTC

I am using syncfusion grid in my project and want to bind JSON format data to grid.But data not display in grid.I have attached sample project.Please let me know how can I achieve it.Can it is not possible to bind JSON format data to grid.I have attached sample project for your reference and in that project I have created hard coded JSON format data but actual data from database and using following line of code we convert it into JOSN format.
                       var JSONString = JsonConvert.SerializeObject(dt);//dt is my datatable

Please help me its urgent.

Attachment: SyncfusionSample_e2f12174.rar

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On April 25, 2016 11:38 AM UTC

Hi Pankaj, 

You are serializing the object to json string using SerializeObject before binding them to Grid which is the cause of the problem. The Grid will accept the result as a LIST of JSON objects and not the JSON string. So we suggest to convert the dataTable and return them as a list. Refer to the following code example. 

        public ActionResult DataSource(Syncfusion.JavaScript.DataManager dm) 
            using (SqlConnection cn = new SqlConnection(connectionStr)) 
                //Getting the records based on skip and top value. 
                SqlCommand cmd = new SqlCommand("SELECT OrderID,CustomerID,EmployeeID,Freight,OrderDate FROM Orders", cn); 
                SqlDataAdapter da = new SqlDataAdapter(cmd); 
                dt = (DataTable)ds.Tables[0]; 
                . . . . . 
            var order = (from DataRow row in dt.Rows 
                         select new Order 
                             OrderID = Convert.ToInt32(row["OrderID"]), 
                             CustomerID = row["CustomerID"].ToString(), 
                             Freight = Convert.ToDecimal(row["Freight"]), 
                             EmployeeID = Convert.ToInt32(row["EmployeeID"]), 
                             OrderDate = Convert.ToDateTime(row["OrderDate"]) 
            return Json(new { result = order, count = count }, JsonRequestBehavior.AllowGet);  

We have prepared a sample that can be downloaded from the following location. 

Seeni Sakthi Kumar S. 


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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon