DataTables warning ... Requested unknown parameter
DataTables warning ... Requested unknown parameter
azka2010
Posts: 2Questions: 0Answers: 0
Hello,
datatable alert me with this message, every time i reload the webpage or go to next page (table paging).
DataTables warning (table id = 'smGrid11_1308053925_39'): Requested unknown parameter '5' from the data source for row 0
and i don't think there's something wrong with the table result. the table still load all data from server completely.
should i just ignore this warning or what ?
Thanks,
Regards,
Azkadina
datatable alert me with this message, every time i reload the webpage or go to next page (table paging).
DataTables warning (table id = 'smGrid11_1308053925_39'): Requested unknown parameter '5' from the data source for row 0
and i don't think there's something wrong with the table result. the table still load all data from server completely.
should i just ignore this warning or what ?
Thanks,
Regards,
Azkadina
This discussion has been closed.
Replies
Thanks a lot if someone give any clue.
Allan
[code]
{
"aaData": [
{
"UserID": 671,
"DeleteColumn": "1377",
"EditColumn": "1377",
"ExplicitPermissions_UserReportRoleID": 0,
"ReportNameColumn": "ProviderTrend",
"ReportRoleColumn": "Impersonate",
"ImpersonateColumn": true,
"ProviderID": 0,
"UserName": "Cramer, Katherine",
"ExplicitPermissionCount": "1",
"DenyColumn": false,
"CommentsColumn": "Test record",
"ImpersonateMedicalGroupProviderID": "1-503",
"ImpersonateProviderName": "ABATE MD,LORRAINE E"
}
]
}
[/code]
The datatable definition looks like this:
[code]
$('#UserReportRole').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": TargetUrl,
"sAjaxDataProp": "aaData",
"sScrollX": '100%',
//"sScrollXInner": "1000px",
"bScrollCollapse": true,
"bAutoWidth": false,
"sScrollY": "440px",
"bProcessing": true,
"bPaginate": false,
"bDestroy": true,
"aoColumns": [
{ /* UserID */"sWidth": "20px", "fnRender": function(obj) {
var str = obj.aData.UserID.toString();
return str;
}, "bUseRendered": false
},
{ /*DeleteColumn*/"sWidth": "56px", "fnRender": function(obj) {
var str = 'Delete';
return str;
}, "bUseRendered": false
},
{ /* EditColumn */"sWidth": "56px", "fnRender": function(obj) {
var ar = [];
ar[ar.length] = "
[code]
{"sEcho":2,"iTotalRecords":"24467","iTotalDisplayRecords":"24467",aaData: [[...],[...]]}
[/code]
this is where the number of records is specified (and without it you're getting NaN) and also in my case aaData is an array of arrays (set of rows). Your JSON looks like an array of objects.
so.. what's your server-side script look like?
[code]
_jsonReturn = JsonConvert.SerializeObject(items);
_jsonReturn = "{\"aaData\":" + _jsonReturn + "}";
[/code]
It will show the data in the table, and the data passes JSON lint OK.
Switched to using aoColumnDefs instead of aoColumns, which helped me figure out that the order of name-value pairs in the JSON was off.
Allan
[quote]allan said:
This message means that DataTables is looking at your data source for array position 0 and not finding it. [/quote]
The message means wrong, as it displays the data in my data source correctly, ergo DataTables was able to find everything.
This is how I set it up:
the table:
[code]
Contact person
Title
Website
Description
B2B
B2C
<?php foreach ($services as $service): ?>
<?php echo Doctrine_Core::getTable('employee')->find($service->getContactPerson()); ?>
<?php echo $service->getTitle() ?>
<?php echo $service->getWebsite() ?>
<?php echo $service->getDescription() ?>
<?php echo $service->getB2b() ?>
<?php echo $service->getB2c() ?>
<?php endforeach; ?>
[/code]
the form:
[code]
<?php echo $form->renderHiddenFields(false) ?>
Back to list
<?php if (!$form->getObject()->isNew()): ?>
<?php echo link_to('Delete', 'service/delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
<?php endif; ?>
<?php echo $form->renderGlobalErrors() ?>
<?php echo $form['contactPerson']->renderLabel() ?>
<?php echo $form['contactPerson']->renderError() ?>
<?php echo $form['contactPerson']->render(array('rel'=>'0' )) ?>
<?php echo $form['title']->renderLabel() ?>
<?php echo $form['title']->renderError() ?>
<?php echo $form['title']->render(array('rel'=>'1' )) ?>
<?php echo $form['website']->renderLabel() ?>
<?php echo $form['website']->renderError() ?>
<?php echo $form['website']->render(array('rel'=>'2' )) ?>
<?php echo $form['description']->renderLabel() ?>
<?php echo $form['description']->renderError() ?>
<?php echo $form['description']->render(array('rel'=>'3' )) ?>
<?php echo $form['b2b']->renderLabel() ?>
<?php echo $form['b2b']->renderError() ?>
<?php echo $form['b2b']->render(array('rel'=>'4','value'=>'1' )) ?>
<?php echo $form['b2c']->renderLabel() ?>
<?php echo $form['b2c']->renderError() ?>
<?php echo $form['b2c']->render(array('rel'=>'5','value'=>'1' )) ?>
[/code]
the action:
[code]
public function executeAdd(sfWebRequest $request)
{
$service = new service();
$service->setContactPerson($_REQUEST['service']['contactPerson']);
$service->setTitle($_REQUEST['service']['title']);
$service->setWebsite($_REQUEST['service']['website']);
$service->setDescription($_REQUEST['service']['description']);
$service->setOrganization(sfContext::getInstance()->getUser()->getGuardUser()->getOrganization());
$service->setB2b($_REQUEST['service']['b2b']);
$service->setB2c($_REQUEST['service']['b2c']);
$service->save();
$this->id = $service->getId();
}
[/code]
the template that returns $id:
[code]
<?php
echo $id;
?>
[/code]
any idea?
Allan
[quote]The message means wrong, as it displays the data in my data source correctly, ergo DataTables was able to find everything.[/quote]
I didn't look careful enough. The row gets added, but the trouble columns are empty until I refresh. So the message is right.
[quote]No idea I'm afraid - did you run your page through the W3C validator? A link would help :-)[/quote]
Thank you. Good idea, I'm doing that just now, 31 Errors, 2 warning(s).
Am I right in assuming that with DataTabels editable checkboxes work the same way like any other form element? Or is there something I have to adhere to?
[quote]
Back to list
ContactPerson
Hans Meiser (Hans Meiser)
Title
Website
Description
B2b
B2c
[/quote]
ha, that assumption was wrong. author of database-editable doesn't seem to like checkboxes.
to make it work you have to edit jquery.dataTables.editable.js on line 283 add
[code]input:checkbox[rel][/code]
EDIT: Lol, I'm dumb.
[code]
else if ( ( this.nodeName.toLowerCase() == "input" && this.type=="checkbox" ) || (this.tagName.toLowerCase() == "input" && this.type=="checkbox"))
if (this.checked)
{sCellValue = '1';}
else {sCellValue = '';}
else
[/code]
[code]
function doMyPageReady()
{
x = document.getElementById("SourcingForm:parts"); // The table
if ( x && x.tBodies && x.tBodies.length>0 )
{
// This works for me, but you're match criteria may vary
if ( x.tBodies[0].innerHTML.length==20 && x.tBodies[0].rows.length ==1 )
{
x.tBodies[0].deleteRow(0);
}
}
oTable = jQuery("#SourcingForm\\:parts").dataTable({
"sScrollY": "200px",
"bScrollInfinite": true,
"iDisplayLength" : -1
});
.
.
.
[/code]
Data is not setting to the table?
[code] function getRows(){
xyzManager.getRows(... , function(data){
//how to set this response data to the table.
dataTable.fnAddData(data);
})
}
dataTable = jQuery("#list").dataTable({
"bJQueryUI": true,
"bAutoWidth":false,
"sPaginationType":"full_numbers",
"bProcessing":true,
"bPaginate":true,
"fnServerData":getRows(),
"aoColumns": getColumns()
});
[/code]
[code]
"fnServerData":getRows,
[/code]
so passing the function, rather than the result of the function.
Allan
Thanks for reply. It is fixed. Problem in JSON format.
I also got this error...
I was declaring a variable inside an "if" and used the variable in my fnAddData(). But the code were not inside the if.
So when dnAddData was called, I had the error.
=> when using an uninitialized variable, you got also the error.
Maybe this case should be managed by the plugin to tell that the parameter passed was not declared ? 'don't knof if it's possible...
Hope this helps! Thank you for this wonderfull plugin!
[code]
The initialization :
if(relation.origin == null)
{
var delRel = "Delete relation";
}
The fnAddData :
$('#tableRelations').dataTable().fnAddData( [
delRel,
radioB,
linkRel,
cdQual,
"pa",
"lieu",
relation.name,
dt,
refRel,
"cdQual"
] );
=> if relation.origin is not null, I get the error
[/code]
SALUDOS
"{\"sEcho\":1,\"iTotalRecords\":\"3\",\"iTotalDisplayRecords\":\"3\",\"aaData\":
[{\"UserName\":\"AAW0\",\"FirstName\":\"John\",\"LastName\":\"Doe\",\"Active\":1},
{\"UserName\":\"LM945\",\"FirstName\":\"John2\",\"LastName\":\"Doe2\",\"Active\":1},
{\"UserName\":\"tgm2\",\"FirstName\":\"Jane\",\"LastName\":\"Doe\",\"Active\":1}]}"
and here is my table initialization:
function LoadDataTables() {
//debugger;
oTable = $("#tblUserList").dataTable({
"bJQueryUI": true,
"iDisplayLength": 25,
"bProcessing": true,
"bServerSide": true,
"bDestroy": true,
"sAjaxSource": "DataBaseTable.ashx?table=IUsers&action=select&usergroup=" + $('#UserGroup').val(),
"sPaginationType": "full_numbers",
"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]]
})
.makeEditable({
sUpdateURL: "DataBaseTable.ashx?table=IUsers&action=update",
sUpdateHttpMethod: "POST",
sAddURL: "DataBaseTable.ashx?table=lUsers&action=new",
sAddHttpMethod: "POST",
sDeleteURL: "DataBaseTable.ashx?table=lUsers&action=delete",
sDeleteHttpMethod: "POST",
"aoColumns":
[
{
indicator: 'Saving...',
cancel: 'Cancel',
submit: 'OK',
tooltip: 'Click to edit UserName'
},
{
indicator: 'Saving...',
cancel: 'Cancel',
submit: 'OK',
tooltip: 'Click to edit First Name'
},
{
indicator: 'Saving...',
cancel: 'Cancel',
submit: 'OK',
tooltip: 'Click to edit Last Name'
},
{
indicator: 'Saving...',
cancel: 'Cancel',
submit: 'OK',
tooltip: 'Click to set User Active/InActive'
}
],
"aaSorting": [[1, "asc"]],
oAddNewRowButtonOptions: { label: "Add...",
icons: { primary: 'ui-icon-plus' }
},
oDeleteRowButtonOptions: { label: "Remove",
icons: { primary: 'ui-icon-trash' }
},
oAddNewRowFormOptions: {
title: 'Add a new User',
show: "blind",
hide: "explode",
modal: true
},
sAddDeleteToolbarSelector: ".dataTables_length"
});
}
@heriquet: In future I'm going to look at having DataTables use the default content for a cell if the parameter is not available. The difficult point is that generally this warning behaviour is good since in most cases it is an error - but sometimes you actually that that. It might be a new init option to switch modes.
Allan
Edit: Just found out that tabletools export (clipboard, excel, pdf) with undefined data instead of actual data. Why? Has anyone encounter the same problem?
Edit: I found this thread: http://datatables.net/forums/discussion/5346/problems-with-1.8-mdataprop-and-tabletools-exporting-csv-excel.../p1
dp i replaced the line# 1414 of the TableTools.js version 2.0.1 with this line:
var mTypeData = dt.aoData[dt.aiDisplay[j]]._aData[dt.aoColumns[i].mDataProp];
and the export worked except the print button which print preview does not show anyrecords for the table eventhough there are 25 record being displayled at that moment.
{
"sExtends": "print",
"bShowAll: false
}
Now the print button worked.
and hi allan, datatable is great :)
I have a problem.
I show with datatables the result of xslt trasformation. I have always the because in my xml i have always these values, but it's possible that I haven't tag, so i received the warning "Requested unknown parameter '1' from the data source for row 0".
The table is not well formed. Is there a way to show the datatable thead and "No results" like tbody in that case??
Ps. Thanks, and sorry for my poor English