f is undefined for ajax result?
f is undefined for ajax result?
cbarr
Posts: 1Questions: 0Answers: 0
I can't for the life of me figure this out, everything I have appears to be correct. Pasting below:
My only guess is that perhaps datatables serverside no likie array of objects...
The documentation states: array aaData The data in a 2D array. Note that you can change the name of this parameter with sAjaxDataProp.
However, in the example at the bottom of the page, the aaData is an array of objects, but the property names seem to reflect an index number? Is that why my code I have below is not working?
[code]
"aaData": [
{
"DT_RowId": "row_7",
"DT_RowClass": "gradeA",
"0": "Gecko",
"1": "Firefox 1.0",
"2": "Win 98+ / OSX.2+",
"3": "1.7",
"4": "A"
},
{
"DT_RowId": "row_8",
"DT_RowClass": "gradeA",
"0": "Gecko",
"1": "Firefox 1.5",
"2": "Win 98+ / OSX.2+",
"3": "1.8",
"4": "A"
}
]
[/code]
HTML:
[code]
WO
Wo Date
Approval Status
Type
Asset
Comp Desc
Assign to
Work Status
Desc
[/code]
JavaScript:
[code]
$('#grid').dataTable({
'sAjaxSource': '/X3Plus/Entities/Starred/WORK/',
'sServerMethod': 'POST',
"aoColumns": [
{ "mData": "wo" },
{ "mData": "date_wo" },
{ "mData": "aprv_stat" },
{ "mData": "wo_type" },
{ "mData": "compid" },
{ "mData": "comp_desc" },
{ "mData": "assignto" },
{ "mData": "workstatus" },
{ "mData": "brief_desc" }
]
});
[/code]
JSON Result:
[code]
"{"sEcho":1,"pageCount":13,"currentPage":1,"iTotalRecords":134,"iTotalDisplayRecords":0,"aaData":[{"wo":2,"date_wo":"05/21/2004","aprv_stat":"","wo_type":"MMETER","compid":"023-23-20-096-01","comp_desc":"BODYMAKER/WELDER","assignto":"","workstatus":"H","brief_desc":""},{"wo":3,"date_wo":"05/21/2004","aprv_stat":"","wo_type":"MMETER","compid":"023-23-24-096-01","comp_desc":"BODYMAKER/WELDER","assignto":"","workstatus":"H","brief_desc":""},{"wo":4,"date_wo":"05/25/2004","aprv_stat":"","wo_type":"MWEEKLY","compid":"023-23-20-096-01","comp_desc":"BODYMAKER/WELDER","assignto":"","workstatus":"H","brief_desc":""},{"wo":5,"date_wo":"05/25/2004","aprv_stat":"","wo_type":"MWEEKLY","compid":"023-23-20-104-01","comp_desc":"BOTTOM DOUBLE SEAMER","assignto":"","workstatus":"H","brief_desc":""},{"wo":6,"date_wo":"05/26/2004","aprv_stat":"","wo_type":"MMETER","compid":"023-23-26-096-01","comp_desc":"BODYMAKER/WELDER","assignto":"","workstatus":"H","brief_desc":""},{"wo":7,"date_wo":"06/18/2004","aprv_stat":"","wo_type":"","compid":"023-21-L2-PRESS- DO N","comp_desc":"LITHO PRESS","assignto":"","workstatus":"H","brief_desc":""},{"wo":15,"date_wo":"03/02/2000","aprv_stat":"","wo_type":"MWEEKLY","compid":"023-23-109-01","comp_desc":"BANDER/STRAPER","assignto":"","workstatus":"H","brief_desc":""},{"wo":22,"date_wo":"10/01/2004","aprv_stat":"","wo_type":"MWEEKLY","compid":"UNKNOWN","comp_desc":"","assignto":"","workstatus":"H","brief_desc":""},{"wo":2000,"date_wo":"03/31/2009","aprv_stat":"","wo_type":"PM","compid":"023-20-01-020-02","comp_desc":"","assignto":"eMaint Test (Sylvain Bujold)","workstatus":"O","brief_desc":"Workflow Fired"},{"wo":2938,"date_wo":"03/20/2012","aprv_stat":"","wo_type":"PREVENTATIVE","compid":"42-022-98-PMP-05","comp_desc":"","assignto":"CC\u0026S (Brian Grassler)","workstatus":"O","brief_desc":"B30 Compound pumping Station - Perform on Tuesday night."}]}"
[/code]
My only guess is that perhaps datatables serverside no likie array of objects...
The documentation states: array aaData The data in a 2D array. Note that you can change the name of this parameter with sAjaxDataProp.
However, in the example at the bottom of the page, the aaData is an array of objects, but the property names seem to reflect an index number? Is that why my code I have below is not working?
[code]
"aaData": [
{
"DT_RowId": "row_7",
"DT_RowClass": "gradeA",
"0": "Gecko",
"1": "Firefox 1.0",
"2": "Win 98+ / OSX.2+",
"3": "1.7",
"4": "A"
},
{
"DT_RowId": "row_8",
"DT_RowClass": "gradeA",
"0": "Gecko",
"1": "Firefox 1.5",
"2": "Win 98+ / OSX.2+",
"3": "1.8",
"4": "A"
}
]
[/code]
HTML:
[code]
WO
Wo Date
Approval Status
Type
Asset
Comp Desc
Assign to
Work Status
Desc
[/code]
JavaScript:
[code]
$('#grid').dataTable({
'sAjaxSource': '/X3Plus/Entities/Starred/WORK/',
'sServerMethod': 'POST',
"aoColumns": [
{ "mData": "wo" },
{ "mData": "date_wo" },
{ "mData": "aprv_stat" },
{ "mData": "wo_type" },
{ "mData": "compid" },
{ "mData": "comp_desc" },
{ "mData": "assignto" },
{ "mData": "workstatus" },
{ "mData": "brief_desc" }
]
});
[/code]
JSON Result:
[code]
"{"sEcho":1,"pageCount":13,"currentPage":1,"iTotalRecords":134,"iTotalDisplayRecords":0,"aaData":[{"wo":2,"date_wo":"05/21/2004","aprv_stat":"","wo_type":"MMETER","compid":"023-23-20-096-01","comp_desc":"BODYMAKER/WELDER","assignto":"","workstatus":"H","brief_desc":""},{"wo":3,"date_wo":"05/21/2004","aprv_stat":"","wo_type":"MMETER","compid":"023-23-24-096-01","comp_desc":"BODYMAKER/WELDER","assignto":"","workstatus":"H","brief_desc":""},{"wo":4,"date_wo":"05/25/2004","aprv_stat":"","wo_type":"MWEEKLY","compid":"023-23-20-096-01","comp_desc":"BODYMAKER/WELDER","assignto":"","workstatus":"H","brief_desc":""},{"wo":5,"date_wo":"05/25/2004","aprv_stat":"","wo_type":"MWEEKLY","compid":"023-23-20-104-01","comp_desc":"BOTTOM DOUBLE SEAMER","assignto":"","workstatus":"H","brief_desc":""},{"wo":6,"date_wo":"05/26/2004","aprv_stat":"","wo_type":"MMETER","compid":"023-23-26-096-01","comp_desc":"BODYMAKER/WELDER","assignto":"","workstatus":"H","brief_desc":""},{"wo":7,"date_wo":"06/18/2004","aprv_stat":"","wo_type":"","compid":"023-21-L2-PRESS- DO N","comp_desc":"LITHO PRESS","assignto":"","workstatus":"H","brief_desc":""},{"wo":15,"date_wo":"03/02/2000","aprv_stat":"","wo_type":"MWEEKLY","compid":"023-23-109-01","comp_desc":"BANDER/STRAPER","assignto":"","workstatus":"H","brief_desc":""},{"wo":22,"date_wo":"10/01/2004","aprv_stat":"","wo_type":"MWEEKLY","compid":"UNKNOWN","comp_desc":"","assignto":"","workstatus":"H","brief_desc":""},{"wo":2000,"date_wo":"03/31/2009","aprv_stat":"","wo_type":"PM","compid":"023-20-01-020-02","comp_desc":"","assignto":"eMaint Test (Sylvain Bujold)","workstatus":"O","brief_desc":"Workflow Fired"},{"wo":2938,"date_wo":"03/20/2012","aprv_stat":"","wo_type":"PREVENTATIVE","compid":"42-022-98-PMP-05","comp_desc":"","assignto":"CC\u0026S (Brian Grassler)","workstatus":"O","brief_desc":"B30 Compound pumping Station - Perform on Tuesday night."}]}"
[/code]
This discussion has been closed.