I am using DataTables and Jeditbale. Everything seems to work well, however, for some reason when I double-click any field within the table, it contains HTML. I have inserted the visual herein. I have not tried anything to fix this problem as I cannot even understand how this would occur. I have googled the problem but most people who report a similar problem just report extra blank spaces; not full html in fields. How can I fix this? If additional code required, can add in due course.
Here is my table code:
<!-- start table listing -->
<table id="myTable" class="stripe hover cell-border row-border">
<thead>
<tr>
<th id="country_id">Country ID</th>
<th id="country">Country Name</th>
<th id="country_import">Import Commnents</th>
<th id="country_export">Export Comments</th>
<th id="country_date_created">Created</th>
<th id="country_date_updated">Updated</th>
<th id="">Updated by</th>
<th id="country_enabled">Enabled?</th>
<th id="">Actions</th>
</tr>
</thead>
<tbody>
<?php
foreach ($query as $row ) {
?>
<tr <?php echo 'id="'.$row->country_id.'"'; ?> >
<td>
<?php echo $row->country_id; ?>
</td>
<td>
<a class='table-action-deletelink' href='/admin/country_view/<?php echo ''.$row->country_id.''; ?> '><?php echo $row->country; ?></a>
</td>
<td>
<?php echo $row->country_import_comments; ?>
</td>
<td>
<?php echo $row->country_export_comments; ?>
</td>
<td>
<?php echo $row->country_date_created; ?>
</td>
<td>
<?php echo $row->country_date_last_updated; ?>
</td>
<td>
<?php echo $row->country_updated_by; ?>
</td>
<td> <?php
if ($row->country_enabled == 1) {
echo '<span class="glyphicon glyphicon-ok" aria-hidden="true" ></span>';
} else {
echo '<span class="glyphicon glyphicon-remove" aria-hidden="true" ></span>';
} ?>
</td>
<td>
<!-- main container -->
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><a role="menuitem" tabindex="-1" href="/admin/country_view/<?php echo ''.$row->country_id.''; ?>">View</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Edit</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Deactivate</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="/admin/country_delete/<?php echo ''.$row->country_id.''; ?> ">Delete</a></li>
</ul>
</div>
</td>
</form>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
Here is my javascript that implements the table:
$(document).ready(function() {
//sDeleteURL: "/Home/DeleteData.php"
$('#myTable').dataTable().makeEditable( {
// some basic config
'bProcessing': true,
'bServerSide': true,
'sAjaxSource': "admin/json_get_countries",
stateSave: true,
"scrollCollapse": true,
"language": {
"lengthMenu": "Display _MENU_ records per page",
"zeroRecords": "Nothing found - sorry",
"info": "Showing page _PAGE_ of _PAGES_",
"infoEmpty": "No records available",
"infoFiltered": "(filtered from _MAX_ total records)"
}
} );
} ); // end of on doc load
You're using jQuery DataTables Editable plugin which internally uses jQuery Jeditable plugin.
According to Jeditable documentation (see Usage with Textile, Markdown, ReST, WiKi), if field contains content other than plain text (HTML, Markdown, etc), you need to use
loadurl
parameter to load content in andsUpdateURL
to save modified value.See Editable DataTable example - custom editors on how
Engine version
field is being edited and saved by using URLs specified inloadurl
andsUpdateURL
parameters.You can make certain columns read-only and not-editable by defining
aoColumns
option and specifyingnull
for corresponding column.aoColumns
is an array holding options for all columns in sequential order, length of this array must be equal to the number of columns in the original HTML table.Example:
See answer to similar problem with Jeditable. However this answer targets Jeditable only and not jQuery DataTables Editable plugin, so the code shown there doesn't apply, just the explanation.