开发者

jQuery DataTables - Reload table upon row addition

I using jquery datatable plugin and having a "Create" button for ajax creation of my db instance. I wish to reload the datatable after the db instance is created, and i spend for more than one day just to find a solution for this. The closest thing i could find is the plugin for DataTables - fnReloadAjax, however, i cant get it to work. I get either error like: fnReloadAjax is not a function OR networkerror: null124234242 is not found (in firebug)

Any idea how can i reload the table so user can get to see the newly inserted d开发者_StackOverflow中文版ata without refreshing the page??

    // Initialize data table
    var myTable = $('#stocktable').dataTable({

        // Try styling
        "sScrollX": "100%",
        "sScrollXInner": "100%",
        "bScrollCollapse": true,

        // To use themeroller theme
        "bJQueryUI": true,
        // To use TableTool plugin
        "sDom": 'T<"clear">lfrtip',
        // Allow single row to be selected
        "oTableTools": {
            "sRowSelect": "single"
        }
        // Use dataTable editable plugin to allow ajax delete
    }).makeEditable({
        // Reference to controller action
        //sAddURL: "/Stock/AddData",
        sDeleteURL: "/Stock/DeleteData",
        sDeleteHttpMethod: "GET"
    });

When i try to call myTable.fnReloadAjax(), i get the error.. Really need help here... Thanks...


You are using datatable in the client-mode; hence, all rows are already in the TBODY. fnReloadAjax works only if you are in the server-side processing mode.

When makeEditable plugin post request to the server page it automatically add row in the TBODY of the table so you do not need to refresh the table - it is already there. If you do not see it maybe it is placed on some other page because when row is added it is positioned according to the current sort criterion.

If you really want to refresh the table only thing you can do is to refresh entire page but new row will still be shown on some other page and you will not see it until you find exact page where it is placed.

Jovan

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜