Getting error string in body and "No Data in Table" on the displayed table.
Getting error string in body and "No Data in Table" on the displayed table.
I have obviously misconfigured something along the way on setting up my instance of the Editor.
I am seeing this line being outputted just below the body tag:
{"id":-1,"error":"","fieldErrors":[],"data":[],"aaData":[{"DT_RowId":"row_73","loc_ID":"73","loc_name":"test","loc_address":"123","loc_city":"ww ww","loc_state":"NY","loc_zip":"60302","loc_country":"US","loc_status":"1"},{"DT_RowId":"row_74","loc_ID":"74","loc_name":"test2","loc_address":"112","loc_city":"test","loc_state":"IA","loc_zip":"60302","loc_country":"Ca","loc_status":"1"},{"DT_RowId":"row_75","loc_ID":"75","loc_name":"test3","loc_address":"123","loc_city":"test","loc_state":"IL","loc_zip":"60601","loc_country":"CA","loc_status":"1"}]}
And I am getting the "No data available in table" in the table on the page.
Here are some code snippets:
[code]
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'location' )
->fields(
Field::inst( 'loc_ID' )
->set( false ),
Field::inst( 'loc_name' )
->validator( 'Validate::required' ),
Field::inst( 'loc_address' )
->validator( 'Validate::required' ),
Field::inst( 'loc_city' )
->validator( 'Validate::required' ),
Field::inst( 'loc_state' )
->validator( 'Validate::required' ),
Field::inst( 'loc_zip' )
->validator( 'Validate::required' ),
Field::inst( 'loc_country' )
->validator( 'Validate::required' ),
Field::inst( 'loc_status' )
->validator( 'Validate::required' )
)
->pkey('loc_ID')
->process( $_POST )
->json();
[/code]
Unfortunately the page this is on is behind a login so I cannot give you a link - sorry.
John
I am seeing this line being outputted just below the body tag:
{"id":-1,"error":"","fieldErrors":[],"data":[],"aaData":[{"DT_RowId":"row_73","loc_ID":"73","loc_name":"test","loc_address":"123","loc_city":"ww ww","loc_state":"NY","loc_zip":"60302","loc_country":"US","loc_status":"1"},{"DT_RowId":"row_74","loc_ID":"74","loc_name":"test2","loc_address":"112","loc_city":"test","loc_state":"IA","loc_zip":"60302","loc_country":"Ca","loc_status":"1"},{"DT_RowId":"row_75","loc_ID":"75","loc_name":"test3","loc_address":"123","loc_city":"test","loc_state":"IL","loc_zip":"60601","loc_country":"CA","loc_status":"1"}]}
And I am getting the "No data available in table" in the table on the page.
Here are some code snippets:
[code]
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'location' )
->fields(
Field::inst( 'loc_ID' )
->set( false ),
Field::inst( 'loc_name' )
->validator( 'Validate::required' ),
Field::inst( 'loc_address' )
->validator( 'Validate::required' ),
Field::inst( 'loc_city' )
->validator( 'Validate::required' ),
Field::inst( 'loc_state' )
->validator( 'Validate::required' ),
Field::inst( 'loc_zip' )
->validator( 'Validate::required' ),
Field::inst( 'loc_country' )
->validator( 'Validate::required' ),
Field::inst( 'loc_status' )
->validator( 'Validate::required' )
)
->pkey('loc_ID')
->process( $_POST )
->json();
[/code]
Unfortunately the page this is on is behind a login so I cannot give you a link - sorry.
John
This discussion has been closed.
Replies
The JSON is actually being output in the HTML page - i.e. you can see it in the browser? Are you including the PHP file directly, or using the sAjaxSource option of DataTables to get the data from it. If you can show us your Javascript that would be very useful.
Allan
[code]
$(document).ready(function() {
var loc_editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "/waitlist_admin.php",
"domTable": "#location",
"fields": [
{
"label": "Name",
"name": "loc_name",
"type": "text"
},
{
"label": "Address",
"name": "loc_address",
"type": "text"
},
{
"label": "City",
"name": "loc_city",
"type": "text"
},
{
"label": "State",
"name": "loc_state",
"default": "NY",
"type": "select",
"ipOpts": [
{
"label": "AL",
"value": "AL"
},
{
"label": "AK",
"value": "AK"
},
{
"label": "AZ",
"value": "AZ"
},
{
"label": "AR",
"value": "AR"
},
{
"label": "CA",
"value": "CA"
},
{
"label": "CO",
"value": "CO"
},
{
"label": "CT",
"value": "CT"
},
{
"label": "DE",
"value": "DE"
},
{
"label": "FL",
"value": "FL"
},
{
"label": "GA",
"value": "GA"
},
{
"label": "HI",
"value": "HI"
},
{
"label": "ID",
"value": "ID"
},
{
"label": "IL",
"value": "IL"
},
{
"label": "IN",
"value": "IN"
},
{
"label": "IA",
"value": "IA"
},
{
"label": "KS",
"value": "KS"
},
{
"label": "KY",
"value": "KY"
},
{
"label": "LA",
"value": "LA"
},
{
"label": "ME",
"value": "ME"
},
{
"label": "MD",
"value": "MD"
},
{
"label": "MA",
"value": "MA"
},
{
"label": "MI",
"value": "MI"
},
{
"label": "MN",
"value": "MN"
},
{
"label": "MS",
"value": "MS"
},
{
"label": "MO",
"value": "MO"
},
{
"label": "MT",
"value": "MT"
},
{
"label": "NE",
"value": "NE"
},
{
"label": "NV",
"value": "NV"
},
{
"label": "NH",
"value": "NH"
},
{
"label": "NJ",
"value": "NJ"
},
{
"label": "NM",
"value": "NM"
},
{
"label": "NY",
"value": "NY"
},
{
"label": "NC",
"value": "NC"
},
{
"label": "ND",
"value": "ND"
},
{
"label": "OH",
"value": "OH"
},
{
"label": "OK",
"value": "OK"
},
{
"label": "OR",
"value": "OR"
},
{
"label": "PA",
"value": "PA"
},
{
"label": "RI",
"value": "RI"
},
{
"label": "SC",
"value": "SC"
},
{
"label": "SD",
"value": "SD"
},
{
"label": "TN",
"value": "TN"
},
{
"label": "TX",
"value": "TX"
},
{
"label": "UT",
"value": "UT"
},
{
"label": "VT",
"value": "VT"
},
{
"label": "VA",
"value": "VA"
},
{
"label": "WA",
"value": "WA"
},
{
"label": "WV",
"value": "WV"
},
{
"label": "WI",
"value": "WI"
},
{
"label": "WY",
"value": "WY"
}
]
},
{
"label": "Zip",
"name": "loc_zip",
"type": "text"
},
{
"label": "Country",
"name": "loc_country",
"default": "US",
"type": "select",
"ipOpts": [
{
"label": "US",
"value": "US"
},
{
"label": "CA",
"value": "CA"
}
]
},
{
"label": "Active",
"name": "loc_status",
"default": "1",
"type": "checkbox",
"ipOpts": [
{
"label": "1",
"value": "1"
}
],
"separator": "|"
}
]
} );
$('#location').dataTable( {
"sDom": "Tfrtip",
"sAjaxSource": "/waitlist_admin.php",
"aoColumns": [
{
"mData": "loc_ID"
},
{
"mData": "loc_name"
},
{
"mData": "loc_address"
},
{
"mData": "loc_city"
},
{
"mData": "loc_state"
},
{
"mData": "loc_zip"
},
{
"mData": "loc_country"
},
{
"mData": "loc_status"
}
],
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [
{ "sExtends": "editor_create", "editor": loc_editor },
{ "sExtends": "editor_edit", "editor": loc_editor },
{ "sExtends": "editor_remove", "editor": loc_editor }
]
}
} );
} );
[/code]
I am including the PHP file directly.
Thanks for the help!
John
Right - I don't think you want to do that :-).
You want something like this in your HTML for the table:
[code]
ID
Name
Address
City
State
Zip
Country
Status
[/code]
DataTables will create the TBODY element for you, and since you've specified the sAjaxSource parameter as where to get the data for the table from, it will also populate the dat ainto the table.
Regards,
Allan
Thanks!
Love the work you do here!
John