如何通过服务URL将json数据与ajax加载绑定到slickgrid? [英] How to bind json data to slickgrid with ajax load through service url?

查看:101
本文介绍了如何通过服务URL将json数据与ajax加载绑定到slickgrid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在使用slickgrids http:// mleibman.github.io/SlickGrid/examples/example6-ajax-loading.html [ ^ ]

所以这里我不知道如何使用json格式的服务URL将数据绑定到网格。?





任何人都可以帮助我...

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...

推荐答案


.ajax({
url:' ; json.aspx / ConvertDataTabletoString'

contentType: application / json; charset = utf-8
类型: POST

dataType: json
错误: function (jqXHR,textStatus,errorThrown){
// debug here
alert ( 这是错误信息);
console .log(jqXHR);
},
成功:功能(数据){

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( 光滑的数据是::: + slickdata) ;
console .log(slickdata);
})
console .log(data);

grid = new Slick.Grid( #teamGrid,数据,列,选项);
.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);


解决方案很简单,但它们没有明确说明如何在他们的维基页面上执行此操作。



SlickGrid希望JSON处于对象形式。因此,如果出于任何原因它是字符串形式只需使用:

JSON.parse(jsonString);



如果你是从ajax,只需这样做:



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:


这篇关于如何通过服务URL将json数据与ajax加载绑定到slickgrid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆