New rows display ID returned from php script until browser refreshed
New rows display ID returned from php script until browser refreshed
(reposting and rephrasing)
I have a datatable working very well, but adding a new row is problematic.
I pass (successfully) all my row data to a php script via sAddURL.
The data goes easily into the database
And I use the echo $id; line to send back the id of the new record in my MySql database to the browser
But...the ID that is echo'd gets broken down by individual characters and then each character put into a column...
that is if the returned ID is 78 then a "7" goes in column 1 and an "8" in column two and then column three throws and error for no data. If I send a string with enough characters in it (that is, echo "new string") then same thing happens, but no error because enough data for all the columns. From my reading it seems that a successful return of an id from the php script is to cause the formAddNewRow data to be copied into the new row, but I surely cannot figure out how to effect this.
If I refresh my browser all the data shows up properly (so it is correctly getting into the database), but I must refresh my browser to see the new data becasue the jquery added row is a convolution of the returned id.
Thank you. (This is a cakePHP developed page)
Link: http://www.culvervdi.org/Annualmeetingagendas/agendalist/2
Here is my code:
SECTION 1: (just to show what code is being pulled in)
<?php
$this->Html->css('http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css', null, array('inline' => false));
$this->Html->css('http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css', null, array('inline' => false));
$this->Html->script('http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js', array('inline' => false));
$this->Html->script('http://code.jquery.com/ui/1.10.3/jquery-ui.js',array('inline'=>false));
$this->Html->script('jquery/jquery.jeditable', array('inline' => false));
$this->Html->script('jquery/jquery.validate.min', array('inline' => false));
$this->Html->script('jquery/jquery.dataTables.editable', array('inline' => false));
?>
SECTION 2: (here is the trouble...and the link at the top of the page has this code to build it)
AddDelete
<?php echo __('Date');?>
<?php echo __('Time');?>
<?php echo __('Agenda title');?>
<?php echo __('Speaker');?>
<?php echo __('Comment');?>
<?php echo __('Display?');?>
<?php
foreach ($meetingagendas as $key=>$meetingagenda)
{
echo "";
echo "".$meetingagenda['Annualmeetingagenda']['date']."";
echo "".$meetingagenda['Annualmeetingagenda']['time']."";
echo "".$meetingagenda['Annualmeetingagenda']['event_title']."";
echo "".$meetingagenda['Annualmeetingagenda']['speaker']."";
echo "".$meetingagenda['Annualmeetingagenda']['comment1']."";
echo "".(($meetingagenda['Annualmeetingagenda']['display'])?"Yes":"No")."";
echo "";
}
?>
<?php echo __('Date');?>
<?php echo __('Time');?>
<?php echo __('Agenda title');?>
<?php echo __('Speaker');?>
<?php echo __('Comment');?>
<?php echo __('Display?');?>
<!--name on the input box is what writes to the database. id is what connects to the column name, but I thought the rel tag was for that-->
Date
Time
Title
Speaker
Comment
Display
Yes
No
var oTable;
$(document).ready(function() {
oTable = $('#agenda').dataTable({
iDisplayLength: 10,
"aoColumns":
[
{"sName":"date"},
{"sName":"time"},
{"sName":"event_title"},
{"sName":"speaker"},
{"sName":"comment1"},
{"sName":"display"}
]
}).makeEditable({
sUpdateURL: "/Annualmeetingagendas/updatefield_ajax",
sAddURL: "/Annualmeetingagendas/add",
sDeleteURL: "/Annualmeetingagendas/deleterow_ajax",
"aoColumns":
[
{tooltip: "Double click to edit"},
{tooltip: "Double click to edit "},
{tooltip: " Double click to edit"},
{tooltip: "Double click to edit "},
{tooltip: "Double click to edit"},
{
tooltip: 'Double click to edit ',
type: 'select',
data: "{'1':'Yes','0':'No'}",
onblur: 'submit'
}
]
});
})
I have a datatable working very well, but adding a new row is problematic.
I pass (successfully) all my row data to a php script via sAddURL.
The data goes easily into the database
And I use the echo $id; line to send back the id of the new record in my MySql database to the browser
But...the ID that is echo'd gets broken down by individual characters and then each character put into a column...
that is if the returned ID is 78 then a "7" goes in column 1 and an "8" in column two and then column three throws and error for no data. If I send a string with enough characters in it (that is, echo "new string") then same thing happens, but no error because enough data for all the columns. From my reading it seems that a successful return of an id from the php script is to cause the formAddNewRow data to be copied into the new row, but I surely cannot figure out how to effect this.
If I refresh my browser all the data shows up properly (so it is correctly getting into the database), but I must refresh my browser to see the new data becasue the jquery added row is a convolution of the returned id.
Thank you. (This is a cakePHP developed page)
Link: http://www.culvervdi.org/Annualmeetingagendas/agendalist/2
Here is my code:
SECTION 1: (just to show what code is being pulled in)
<?php
$this->Html->css('http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css', null, array('inline' => false));
$this->Html->css('http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css', null, array('inline' => false));
$this->Html->script('http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js', array('inline' => false));
$this->Html->script('http://code.jquery.com/ui/1.10.3/jquery-ui.js',array('inline'=>false));
$this->Html->script('jquery/jquery.jeditable', array('inline' => false));
$this->Html->script('jquery/jquery.validate.min', array('inline' => false));
$this->Html->script('jquery/jquery.dataTables.editable', array('inline' => false));
?>
SECTION 2: (here is the trouble...and the link at the top of the page has this code to build it)
AddDelete
<?php echo __('Date');?>
<?php echo __('Time');?>
<?php echo __('Agenda title');?>
<?php echo __('Speaker');?>
<?php echo __('Comment');?>
<?php echo __('Display?');?>
<?php
foreach ($meetingagendas as $key=>$meetingagenda)
{
echo "";
echo "".$meetingagenda['Annualmeetingagenda']['date']."";
echo "".$meetingagenda['Annualmeetingagenda']['time']."";
echo "".$meetingagenda['Annualmeetingagenda']['event_title']."";
echo "".$meetingagenda['Annualmeetingagenda']['speaker']."";
echo "".$meetingagenda['Annualmeetingagenda']['comment1']."";
echo "".(($meetingagenda['Annualmeetingagenda']['display'])?"Yes":"No")."";
echo "";
}
?>
<?php echo __('Date');?>
<?php echo __('Time');?>
<?php echo __('Agenda title');?>
<?php echo __('Speaker');?>
<?php echo __('Comment');?>
<?php echo __('Display?');?>
<!--name on the input box is what writes to the database. id is what connects to the column name, but I thought the rel tag was for that-->
Date
Time
Title
Speaker
Comment
Display
Yes
No
var oTable;
$(document).ready(function() {
oTable = $('#agenda').dataTable({
iDisplayLength: 10,
"aoColumns":
[
{"sName":"date"},
{"sName":"time"},
{"sName":"event_title"},
{"sName":"speaker"},
{"sName":"comment1"},
{"sName":"display"}
]
}).makeEditable({
sUpdateURL: "/Annualmeetingagendas/updatefield_ajax",
sAddURL: "/Annualmeetingagendas/add",
sDeleteURL: "/Annualmeetingagendas/deleterow_ajax",
"aoColumns":
[
{tooltip: "Double click to edit"},
{tooltip: "Double click to edit "},
{tooltip: " Double click to edit"},
{tooltip: "Double click to edit "},
{tooltip: "Double click to edit"},
{
tooltip: 'Double click to edit ',
type: 'select',
data: "{'1':'Yes','0':'No'}",
onblur: 'submit'
}
]
});
})
This discussion has been closed.
Replies
Thanks for picking up the DataTables support option. I should note that themakeEditable plug-in is not part of the DataTables project, it is a 3rd party plug-in (which appears to be unsupported but the author now), so what I can do to help with the plug-in is a little limited.
Having said that, I can take a look to see what is going wrong. Are you able to send me login credentials for your site so I can take a look and see what is going wrong?
Thanks,
Allan