Click here to Skip to main content
15,892,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi all
I am working with slickgrids http://mleibman.github.io/SlickGrid/examples/example6-ajax-loading.html[^]
So here I don't know how to bind the data to the grid using service url in json format.?


Can any one help me out...
Posted

JavaScript
$.ajax({
   url: ';json.aspx/ConvertDataTabletoString',
            
   contentType: "application/json;charset=utf-8",
   type: "POST",
                  
   dataType: "json",
   error: function (jqXHR, textStatus, errorThrown) {
      // debug here
      alert("hi this is error message");
      console.log(jqXHR);
   },
   success: function (data) {
                     
      for (var i = 0; i < data.length; i++) {
         slickdata[i] = {
            recid: data[i].recid,
            fname: data[i].fname,
            lname: data[i].lname,
            email: data[i].email,
            sdate: data[i].sdate,
      };
   }
   alert("slick data is:::" + slickdata);
   console.log(slickdata);
})
   console.log(data);
                     
   grid = new Slick.Grid("#teamGrid", data, columns, options);
 
Share this answer
 
v2
Comments
Member 10985339 1-Sep-14 9:03am    
var jqxhr = $.getJSON('http://localhost:50305/Service1.svc/json/EmployeeDetails', function (data) {
console.log(data);

dataView.setItems(data, "EmpId");
console.log(dataView);
grid = new Slick.Grid("#teamGrid", dataView.rows, columns, options);
The solution is simple, but they do not explicitly state how to do this on their wiki page.

SlickGrid expects JSON to be in object form. So if for any reason it is in string form just use:
JSON.parse(jsonString);

If you're loading from ajax, just simply do this:

JavaScript
$.getJSON("file.json", function(data) {
    grid = new Slick.Grid("#teamGrid", data, columns, options);
}


Heath Dinkins
Software Engineer II Consultant at Leidos
 
Share this answer
 
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900