admin管理员组文章数量:1026925
I am working on creating a table form using jTable plugin. It mainly focus for ASP or PHP MVC but I'm trying to implement it with javascript/html and mongo backend.
I went through entire jTable API documentation and I found out there is possibility of populating json schema api into table, quite similiar in flexigrid.
The code looks like:
$(document).ready(function () {
$('#feeds-table').jtable({
title: 'Accounts',
pageSize: 15,
ajaxSettings: {
type: 'GET',
dataType: 'json'
},
actions: {
},
fields: {
id: {
key: true,
list: false
},
username: {
title: 'Username',
width: '10%'
},
email: {
title: 'Email',
width: '10%'
},
applications: {
title: 'Applications',
width: '10%'
},
sites: {
title: 'Sites',
width: '10%'
},
verticals: {
title: 'Verticals',
width: '10%'
},
roles: {
title: 'Roles',
width: '10%'
},
profiles: {
title: 'Record date',
width: '30%',
type: 'date',
create: false,
edit: false
}
}
});
});
If anyone can help me to find out where should I use URL property or is there any other method in the API reference to GET the data and display in table. Please let me know!
I am working on creating a table form using jTable plugin. It mainly focus for ASP or PHP MVC but I'm trying to implement it with javascript/html and mongo backend.
I went through entire jTable API documentation and I found out there is possibility of populating json schema api into table, quite similiar in flexigrid.
The code looks like:
$(document).ready(function () {
$('#feeds-table').jtable({
title: 'Accounts',
pageSize: 15,
ajaxSettings: {
type: 'GET',
dataType: 'json'
},
actions: {
},
fields: {
id: {
key: true,
list: false
},
username: {
title: 'Username',
width: '10%'
},
email: {
title: 'Email',
width: '10%'
},
applications: {
title: 'Applications',
width: '10%'
},
sites: {
title: 'Sites',
width: '10%'
},
verticals: {
title: 'Verticals',
width: '10%'
},
roles: {
title: 'Roles',
width: '10%'
},
profiles: {
title: 'Record date',
width: '30%',
type: 'date',
create: false,
edit: false
}
}
});
});
If anyone can help me to find out where should I use URL property or is there any other method in the API reference to GET the data and display in table. Please let me know!
Share Improve this question edited May 7, 2013 at 12:27 Shobhit Sharma asked May 7, 2013 at 12:05 Shobhit SharmaShobhit Sharma 6341 gold badge10 silver badges19 bronze badges2 Answers
Reset to default 1You can directly load JSON data by setting the 'listAction' to a JSON document .
Example:
actions: {
listAction: 'url/file.json',
},
Your JSON file needs to have the same fields specified and the next structure:
{
"Result":"OK",
"Records":[
{"PersonId":1,"Name":"Benjamin Button","Age":17,"RecordDate":"\/Date(1320259705710)\/"},
{"PersonId":2,"Name":"Douglas Adams","Age":42,"RecordDate":"\/Date(1320259705710)\/"},
{"PersonId":3,"Name":"Isaac Asimov","Age":26,"RecordDate":"\/Date(1320259705710)\/"},
{"PersonId":4,"Name":"Thomas More","Age":65,"RecordDate":"\/Date(1320259705710)\/"}
]
}
The mon way is to point the 'listAction' to a server side script (PHP,ASP.NET...) that return the above JSON object.
Check the listAction
API reference for more information:
ApiReference-listAction
Use the addRecord
action. It gives you the option to specify clientOnly: true
which will prevent jtable from making a server call when you edit a row.
More Information - jtable-addRecord
I am working on creating a table form using jTable plugin. It mainly focus for ASP or PHP MVC but I'm trying to implement it with javascript/html and mongo backend.
I went through entire jTable API documentation and I found out there is possibility of populating json schema api into table, quite similiar in flexigrid.
The code looks like:
$(document).ready(function () {
$('#feeds-table').jtable({
title: 'Accounts',
pageSize: 15,
ajaxSettings: {
type: 'GET',
dataType: 'json'
},
actions: {
},
fields: {
id: {
key: true,
list: false
},
username: {
title: 'Username',
width: '10%'
},
email: {
title: 'Email',
width: '10%'
},
applications: {
title: 'Applications',
width: '10%'
},
sites: {
title: 'Sites',
width: '10%'
},
verticals: {
title: 'Verticals',
width: '10%'
},
roles: {
title: 'Roles',
width: '10%'
},
profiles: {
title: 'Record date',
width: '30%',
type: 'date',
create: false,
edit: false
}
}
});
});
If anyone can help me to find out where should I use URL property or is there any other method in the API reference to GET the data and display in table. Please let me know!
I am working on creating a table form using jTable plugin. It mainly focus for ASP or PHP MVC but I'm trying to implement it with javascript/html and mongo backend.
I went through entire jTable API documentation and I found out there is possibility of populating json schema api into table, quite similiar in flexigrid.
The code looks like:
$(document).ready(function () {
$('#feeds-table').jtable({
title: 'Accounts',
pageSize: 15,
ajaxSettings: {
type: 'GET',
dataType: 'json'
},
actions: {
},
fields: {
id: {
key: true,
list: false
},
username: {
title: 'Username',
width: '10%'
},
email: {
title: 'Email',
width: '10%'
},
applications: {
title: 'Applications',
width: '10%'
},
sites: {
title: 'Sites',
width: '10%'
},
verticals: {
title: 'Verticals',
width: '10%'
},
roles: {
title: 'Roles',
width: '10%'
},
profiles: {
title: 'Record date',
width: '30%',
type: 'date',
create: false,
edit: false
}
}
});
});
If anyone can help me to find out where should I use URL property or is there any other method in the API reference to GET the data and display in table. Please let me know!
Share Improve this question edited May 7, 2013 at 12:27 Shobhit Sharma asked May 7, 2013 at 12:05 Shobhit SharmaShobhit Sharma 6341 gold badge10 silver badges19 bronze badges2 Answers
Reset to default 1You can directly load JSON data by setting the 'listAction' to a JSON document .
Example:
actions: {
listAction: 'url/file.json',
},
Your JSON file needs to have the same fields specified and the next structure:
{
"Result":"OK",
"Records":[
{"PersonId":1,"Name":"Benjamin Button","Age":17,"RecordDate":"\/Date(1320259705710)\/"},
{"PersonId":2,"Name":"Douglas Adams","Age":42,"RecordDate":"\/Date(1320259705710)\/"},
{"PersonId":3,"Name":"Isaac Asimov","Age":26,"RecordDate":"\/Date(1320259705710)\/"},
{"PersonId":4,"Name":"Thomas More","Age":65,"RecordDate":"\/Date(1320259705710)\/"}
]
}
The mon way is to point the 'listAction' to a server side script (PHP,ASP.NET...) that return the above JSON object.
Check the listAction
API reference for more information:
ApiReference-listAction
Use the addRecord
action. It gives you the option to specify clientOnly: true
which will prevent jtable from making a server call when you edit a row.
More Information - jtable-addRecord
本文标签: javascriptHow to load JSON Data in jQueryjTable pluginStack Overflow
版权声明:本文标题:javascript - How to load JSON Data in jQuery-jTable plugin? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745655916a2161594.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论