How to reload the datatable(jquery) data?

后端 未结 10 2482
萌比男神i
萌比男神i 2020-12-05 05:39

How to reload the selected tab? Actually I have problem with reloading part. When I add my data I\'ll successfully saved in datatable but in id field in database it shows pr

10条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-05 05:57

    Use the fnReloadAjax() by the DataTables.net author.

    I'm copying the source code below - in case the original ever moves:

    $.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
    {
        if ( typeof sNewSource != 'undefined' && sNewSource != null )
        {
            oSettings.sAjaxSource = sNewSource;
        }
        this.oApi._fnProcessingDisplay( oSettings, true );
        var that = this;
        var iStart = oSettings._iDisplayStart;
        var aData = [];
    
        this.oApi._fnServerParams( oSettings, aData );
    
        oSettings.fnServerData( 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

提交回复
热议问题