DataTables warning (table id = 'dataTable'): Requested unknown parameter 'Entity_Id' from the data s
DataTables warning (table id = 'dataTable'): Requested unknown parameter 'Entity_Id' from the data s
I'm trying to use the DataTables (CRUD) plugin that can be found on DataTables Data Manager (CRUD) Add-on
I'm using
DataTables 1.9.4
jquery.datatables.editable.js 1.3
jQuery 1.9
So far everything is working fine except when I try to add a new record. I've followed the instruction on the example on this link Adding Records and the WiKi Example
This is the code I'm using to insert the new record
[code]
// Open the db connection
$link = dbConnect('dbname');
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
// Prepare the insert
$updateQuery = "INSERT INTO $tblname ($columns) VALUES ($valuesTemp)";
$id = 0;
$entity_id = array();
// Run the insert and if it's been succesful enter the if condition
if(sqlsrv_query( $link, $updateQuery ) == true){
// Get the last inserted ID
$getId = "SELECT MAX(Entity_Id) AS 'Id' FROM HoldingTable WHERE Client_Id = '$client_id' AND Project_Id = '$project_id'";
$result = sqlsrv_query( $link, $getId, $params, $options );
while ( $aRow = sqlsrv_fetch_array( $result, SQLSRV_FETCH_NUMERIC ) )
{
$entity_id = $aRow;
}
$id = $entity_id[0];
// Close the connection.
sqlsrv_close( $link );
// return the id
echo $id;
}else{
// If the insert failed display an error
echo 'There\'s been an error: ';
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."
";
echo "code: ".$error[ 'code']."
";
echo "message: ".$error[ 'message']."
";
}
}
}
[/code]
I tried deleting all the code from the adddata script and just leave a random hard coded number and still get the same error. This seems to happen at the moment of refreshing the datatable.
If run firebug and check the network, I'm getting the numeric ID correctly like on the examples on the website but I keep getting a popup message with the following error when trying to refresh the table after the insert.
DataTables warning (table id = 'dataTable'): Requested unknown parameter 'Entity_Id' from the data source for row 2 (This number changes depending on how many rows I've got)
That message was with two records and after inserting a third one.
I've tried moving the select that gets the id to run before the insert but still get the same error and can't figure out why.
I still haven't found a solution for this. I've been googling around and most of the post talk about null values in the JSON so I've modified the aoColumns and added this sDefaultContent: "" to have blank values instead of nulls. But I still get the same error.
Here's the link so you can see the error
http://dev.shocklogic.com/scripts/jmevent/databaseedit.php?H='5.15%20Edit%20Holding%20Table'&Client_Id='SHOCKLOGIC'&Project_Id='0100'&System_Id=2&TableName='HoldingTable'
Click on add, fill out the form the miminum required fields are First Name, Family Name, Country and Email. After you click ok you get the error.
I'm using
DataTables 1.9.4
jquery.datatables.editable.js 1.3
jQuery 1.9
So far everything is working fine except when I try to add a new record. I've followed the instruction on the example on this link Adding Records and the WiKi Example
This is the code I'm using to insert the new record
[code]
// Open the db connection
$link = dbConnect('dbname');
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
// Prepare the insert
$updateQuery = "INSERT INTO $tblname ($columns) VALUES ($valuesTemp)";
$id = 0;
$entity_id = array();
// Run the insert and if it's been succesful enter the if condition
if(sqlsrv_query( $link, $updateQuery ) == true){
// Get the last inserted ID
$getId = "SELECT MAX(Entity_Id) AS 'Id' FROM HoldingTable WHERE Client_Id = '$client_id' AND Project_Id = '$project_id'";
$result = sqlsrv_query( $link, $getId, $params, $options );
while ( $aRow = sqlsrv_fetch_array( $result, SQLSRV_FETCH_NUMERIC ) )
{
$entity_id = $aRow;
}
$id = $entity_id[0];
// Close the connection.
sqlsrv_close( $link );
// return the id
echo $id;
}else{
// If the insert failed display an error
echo 'There\'s been an error: ';
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."
";
echo "code: ".$error[ 'code']."
";
echo "message: ".$error[ 'message']."
";
}
}
}
[/code]
I tried deleting all the code from the adddata script and just leave a random hard coded number and still get the same error. This seems to happen at the moment of refreshing the datatable.
If run firebug and check the network, I'm getting the numeric ID correctly like on the examples on the website but I keep getting a popup message with the following error when trying to refresh the table after the insert.
DataTables warning (table id = 'dataTable'): Requested unknown parameter 'Entity_Id' from the data source for row 2 (This number changes depending on how many rows I've got)
That message was with two records and after inserting a third one.
I've tried moving the select that gets the id to run before the insert but still get the same error and can't figure out why.
I still haven't found a solution for this. I've been googling around and most of the post talk about null values in the JSON so I've modified the aoColumns and added this sDefaultContent: "" to have blank values instead of nulls. But I still get the same error.
Here's the link so you can see the error
http://dev.shocklogic.com/scripts/jmevent/databaseedit.php?H='5.15%20Edit%20Holding%20Table'&Client_Id='SHOCKLOGIC'&Project_Id='0100'&System_Id=2&TableName='HoldingTable'
Click on add, fill out the form the miminum required fields are First Name, Family Name, Country and Email. After you click ok you get the error.
This discussion has been closed.
Replies
I've added sDefaultContent:"" to each one of the column declarations in aoColumns and the error is gone now.
So my aoColumns look something like this now
[code]
"aoColumns": [
{ "mDataProp": "checkbox" ,"bSortable":false ,sDefaultContent:"", "sWidth" : "1%"},
{ "mDataProp": "Entity_Id" , "bSortable":true, "bVisible": false, sDefaultContent: "", "sWidth" : "1%" },
{ "mDataProp": "External_Id" ,"bSortable":true, sDefaultContent: "", "sWidth" : "1%" },
{ "mDataProp": "Family_Name" ,"bSortable":true, sDefaultContent: "", "sWidth" : "5%" },
{ "mDataProp": "First_Name" ,"bSortable":true, sDefaultContent: "", "sWidth" : "5%" },
{ "mDataProp": "Prefix_Title" ,"bSortable":true, sDefaultContent: "", "sWidth" : "1%" },
{ "mDataProp": "Suffix_Title" ,"bSortable":true, sDefaultContent: "", "sWidth" : "1%" },
{ "mDataProp": "Company" ,"bSortable":true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "Address_1" ,"bSortable":true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "Address_2" ,"bSortable":true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "Address_3" ,"bSortable":true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "Address_4" ,"bSortable":true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "Zip_Code" ,"bSortable":true, sDefaultContent: "", "sWidth" : "1%" },
{ "mDataProp": "City" ,"bSortable":true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "Country_Code" ,"bSortable":true, sDefaultContent: "", "sWidth" : "1%" },
{ "mDataProp": "Telephone" ,"bSortable":true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "Telefax" ,"bSortable":true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "EMail" ,"bSortable":true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "EMail2" ,"bSortable":true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "Session_Id" ,"bSortable":true, sDefaultContent: "", "bVisible": false, "sWidth" : "2%" },
{ "mDataProp": "Gender" ,"bSortable":true, sDefaultContent: "", "sWidth" : "1%" },
{ "mDataProp": "JMUser_Id" ,"bSortable":true, sDefaultContent: "", "bVisible": false, "sWidth" : "1%" },
{ "mDataProp": "Password" ,"bSortable":true, sDefaultContent: "", "bVisible": false, "sWidth" : "1%" },
{ "mDataProp": "ExtraField01" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "ExtraField02" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "ExtraField03" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "ExtraField04" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "ExtraField05" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "ExtraField06" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "ExtraField07" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "ExtraField08" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "ExtraField09" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "ExtraField10" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "Mobile" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "URL" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "Passport_Number" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "Nationality" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "ID_Number" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "Date_Of_Birth" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "2%" },
{ "mDataProp": "Special_Needs_Physical" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "3%" },
{ "mDataProp": "Special_Needs_Dietary" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "3%" },
{ "mDataProp": "First_Name_For_Badge" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "5%" },
{ "mDataProp": "Family_Name_For_Badge" ,"bSortable":true, sDefaultContent: "", "bVisible": true, "sWidth" : "5%" },
{ "mDataProp": "Biography" ,"bSortable":true, "bVisible": true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "VAT_Number" ,"bSortable":true, "bVisible": true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "Membership_No" ,"bSortable":true, "bVisible": true, sDefaultContent: "", "sWidth" : "2%" },
{ "mDataProp": "Participant_Template" ,"bSortable":true, "bVisible": true, sDefaultContent: "", "sWidth" : "1%" },
{ "mDataProp": "Language_Code" ,"bSortable":true, "bVisible": true, sDefaultContent: "", "sWidth" : "1%" }
],
[/code]
All sorted!