Reloading the table data when data is added, deleted or edited
Reloading the table data when data is added, deleted or edited
I am having a issue trying to reload data in my table when entries are added, removed or edited. All these functions happen via ajax post calls in jQuery. I am using the fnReloadAjax plugin.
Here's the debug data from bookmarklet http://debug.datatables.net/otoqen
Here's the relevant code snippets
HTML
[code]
Name
Price
Ships
Delete |
Edit
100000
Add Group
[/code]
jQuery
[code]
var oTable
jQuery(document).ready(function($) {
/* Reload data in datatable when value is updated */
$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
{
if ( typeof sNewSource != 'undefined' && sNewSource != null ) {
oSettings.sAjaxSource = sNewSource;
}
// Server-side processing should just call fnDraw
if ( oSettings.oFeatures.bServerSide ) {
this.fnDraw();
return;
}
this.oApi._fnProcessingDisplay( oSettings, true );
var that = this;
var iStart = oSettings._iDisplayStart;
var aData = [];
this.oApi._fnServerParams( oSettings, aData );
oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aData, function(json) {
/* Clear the old information from the table */
that.oApi._fnClearTable( oSettings );
/* Got the data - add it to the table */
var aData = (oSettings.sAjaxDataProp !== "") ?
that.oApi._fnGetObjectDataFn( oSettings.sAjaxDataProp )( json ) : json;
for ( var i=0 ; i
Here's the debug data from bookmarklet http://debug.datatables.net/otoqen
Here's the relevant code snippets
HTML
[code]
Name
Price
Ships
Delete |
Edit
100000
Add Group
[/code]
jQuery
[code]
var oTable
jQuery(document).ready(function($) {
/* Reload data in datatable when value is updated */
$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
{
if ( typeof sNewSource != 'undefined' && sNewSource != null ) {
oSettings.sAjaxSource = sNewSource;
}
// Server-side processing should just call fnDraw
if ( oSettings.oFeatures.bServerSide ) {
this.fnDraw();
return;
}
this.oApi._fnProcessingDisplay( oSettings, true );
var that = this;
var iStart = oSettings._iDisplayStart;
var aData = [];
this.oApi._fnServerParams( oSettings, aData );
oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aData, function(json) {
/* Clear the old information from the table */
that.oApi._fnClearTable( oSettings );
/* Got the data - add it to the table */
var aData = (oSettings.sAjaxDataProp !== "") ?
that.oApi._fnGetObjectDataFn( oSettings.sAjaxDataProp )( json ) : json;
for ( var i=0 ; i
This discussion has been closed.
Replies
Allan
Appreciate the great work and prompt help.
Uncaught TypeError: Object has no method getElementsByTagName
I have edit working but it has one issue. My column looks like this
[code]
Ships
Delete Group |
Edit
[/code]
But I get only the value for div class groupname and want to update only that. If I use the following code
[code]
oTable.fnUpdate([ groupname, perhead ] , index);
[/code]
it replaces Ships with the new value in the td class groupfield.
Using jQuery, so far, I used to do
[code]
$('.groupname').text(groupname);
[/code]
So it used to leave rest of the items as they are. How can I manage to do that?
Additionally, the newly added entries do not get sorted alphabetically. They're sorted at the top.