sAjaxDataProp
sAjaxDataProp
bxp8561
Posts: 3Questions: 0Answers: 0
Hello
I am using the following code for dataTables. i am getting aData is undefined error
Pls help...
[code]
function populateValueAddTable() {
valueAddOTable = $('#valueAddTable').dataTable({
"bDestroy" : true,
"bServerSide" : false,
"bProcessing" : true,
"sAjaxDataProp" : "list.values",
"sAjaxSource" : "rs/services/json/getValueAdd",
"sScrollY" : 200,
"bJQueryUI" : true,
"sPaginationType" : "full_numbers",
"aoColumns" : [ {
"sTitle" : "ID",
"mDataProp" : "id"
}]
});
}
[/code]
and JSON is
[quote]
{
"list": [
{
"values": [
{
"id": 1,
"entryDate": "12/12/12",
"purpose": "yes",
"workStream": "BASIS",
"details": "Details",
"benefits": "Benefits",
"plannedImplementationDate": "12/10/12",
"proposedBy": "bxp8561"
},
{
"id": 14,
"entryDate": "12/12/13",
"purpose": "no",
"workStream": "BASIS",
"details": "New",
"benefits": "money",
"plannedImplementationDate": "12/1/13",
"proposedBy": "bxp8561"
}
]
}
]
}
[/quote]
I am using the following code for dataTables. i am getting aData is undefined error
Pls help...
[code]
function populateValueAddTable() {
valueAddOTable = $('#valueAddTable').dataTable({
"bDestroy" : true,
"bServerSide" : false,
"bProcessing" : true,
"sAjaxDataProp" : "list.values",
"sAjaxSource" : "rs/services/json/getValueAdd",
"sScrollY" : 200,
"bJQueryUI" : true,
"sPaginationType" : "full_numbers",
"aoColumns" : [ {
"sTitle" : "ID",
"mDataProp" : "id"
}]
});
}
[/code]
and JSON is
[quote]
{
"list": [
{
"values": [
{
"id": 1,
"entryDate": "12/12/12",
"purpose": "yes",
"workStream": "BASIS",
"details": "Details",
"benefits": "Benefits",
"plannedImplementationDate": "12/10/12",
"proposedBy": "bxp8561"
},
{
"id": 14,
"entryDate": "12/12/13",
"purpose": "no",
"workStream": "BASIS",
"details": "New",
"benefits": "money",
"plannedImplementationDate": "12/1/13",
"proposedBy": "bxp8561"
}
]
}
]
}
[/quote]
This discussion has been closed.
Replies
Allan
if i were to remove the headers from the JSON like this, how should i write the datatable JS method?
I dont want to do a loop...
[code]
[
{
"id": 1,
"entryDate": "12/12/12",
"purpose": "yes",
"workStream": "BASIS",
"details": "Details",
"benefits": "Benefits",
"plannedImplementationDate": "12/10/12",
"proposedBy": "bxp8561"
},
{
"id": 14,
"entryDate": "12/12/13",
"purpose": "no",
"workStream": "BASIS",
"details": "New",
"benefits": "money",
"plannedImplementationDate": "12/1/13",
"proposedBy": "bxp8561"
}
]
[/code]
[code]
function populateValueAddTable() {
valueAddOTable = $('#valueAddTable').dataTable({
"bDestroy" : true,
"bServerSide" : false,
"bProcessing" : true,
"sAjaxSource" : "rs/services/json/getValueAdd",
"sScrollY" : 200,
"bJQueryUI" : true,
"sPaginationType" : "full_numbers",
"aoColumns" : [ {
"sTitle" : "Entry Date",
"mData" : "entryDate"
}, {
"sTitle" : "Purpose",
"mData" : "purpose"
}, {
"sTitle" : "Work Stream",
"mData" : "workStream"
}, {
"sTitle" : "Details",
"mData" : "details"
}, {
"sTitle" : "Benefits",
"mData" : "benefits"
}, {
"sTitle" : "Planned Implementation Date",
"mData" : "plannedImplementationDate"
}, {
"sTitle" : "Proposed By",
"mData" : "proposedBy"
} ],
"fnServerData" : function(sSource, aoData, fnCallback) {
$.getJSON(sSource, aoData, function(json) {
map = {};
map["aaData"] = json;
fnCallback(map);
});
}
});
[/code]
and my json is
[code]
[{"id":1,"entryDate":"12/12/12","purpose":"yes","workStream":"BASIS","details":"Details","benefits":"Benefits","plannedImplementationDate":"12/10/12","proposedBy":"bxp8561"},{"id":14,"entryDate":"12/12/13","purpose":"no","workStream":"BASIS","details":"New","benefits":"money","plannedImplementationDate":"12/1/13","proposedBy":"bxp8561"},{"id":15,"entryDate":"12/12/13","purpose":"no","workStream":"BASIS","details":"New","benefits":"money","plannedImplementationDate":"12/1/13","proposedBy":"bxp8561"},{"id":16,"entryDate":"12/12/13","purpose":"no","workStream":"BASIS","details":"New","benefits":"money","plannedImplementationDate":"12/1/13","proposedBy":"bxp8561"},{"id":17,"entryDate":"12/12/13","purpose":"no","workStream":"BASIS","details":"New","benefits":"money","plannedImplementationDate":"12/1/13","proposedBy":"bxp8561"},{"id":18,"entryDate":"12/12/13","purpose":"no","workStream":"BASIS","details":"New","benefits":"money","plannedImplementationDate":"12/1/13","proposedBy":"bxp8561"},{"id":19,"entryDate":"12/12/13","purpose":"no","workStream":"BASIS","details":"New","benefits":"money","plannedImplementationDate":"12/1/13","proposedBy":"bxp8561"},{"id":20,"entryDate":"12/12/13","purpose":"no","workStream":"BASIS","details":"New","benefits":"money","plannedImplementationDate":"12/1/13","proposedBy":"bxp8561"},{"id":21,"entryDate":"12/12/13","purpose":"no","workStream":"BASIS","details":"New","benefits":"money","plannedImplementationDate":"12/1/13","proposedBy":"bxp8561"},{"id":22,"entryDate":"12/12/13","purpose":"no","workStream":"BASIS","details":"New","benefits":"money","plannedImplementationDate":"12/1/13","proposedBy":"bxp8561"},{"id":23,"entryDate":"12/12/13","purpose":"no","workStream":"BASIS","details":"New","benefits":"money","plannedImplementationDate":"12/1/13","proposedBy":"bxp8561"}]
[/code]
Allan