即时更改设置值?

2021/01/12 11:31 · jquery ·  · 0评论

是否可以即时更改jQuery DataTables设置值。我的问题是下一个,我需要随时更改sAjaxSource已经尝试过这样的事情:

var oDefault = {
    "bServerSide": true,
    "bProcessing": true,
    "bJQueryUI": true,
    "bLengthChange": false,
    "bFilter": true,
    "iDisplayLength": 8,
    "sAjaxSource": "my.php?" + "idKat="+aData[3],
    "aaSorting": [[ 0, "asc" ],[ 3, "asc" ]],
    "sDom": '<"top"ir>t<"bottom"pf<"clear">',
    "sPaginationType": "full_numbers",
    "oLanguage": {
        "sUrl": "<?php echo $full_path_jezik_2;?>"
    },
    "aoColumns": [
        { "sName": "rb","sWidth": "15%", "sClass": "center","sType": "numeric" },
        { "sName": "chkZaBrisanje","sWidth": "20%", "sClass": "center", "bSortable":false },
        { "sName": "rbPrvaSlika","sWidth": "15%", "sClass": "center","bSortable":false  },
        { "sName": "nazivSlike","sWidth": "50%", "sClass": "center", "sSortDataType": "dom-text"  }
    ]
};

var oST = $.extend( true, {}, oDefault );
oST.sAjaxSource = "my.php?" + "idKat="+aData[3];

alert(oST.sAjaxSource);

if (typeof oTable == 'undefined') {
    oTable = $("#my-table").dataTable(oST);
}
else
{               
    oTable.fnDraw();
} 

aData[3]单击更改我的

你有没有尝试过

 oTable = $("#my-table").dataTable(oST);
 var oSettings = oTable.fnSettings();
 oSettings.sAjaxSource  = "new value";

您可以使用fnReloadAjax()函数,请参阅官方数据表站点上的插件。

对于DataTables 1.10+

使用ajax.url()如下所示的API方法来设置Ajax URL并立即从新源中加载数据:

var table = $('#example').DataTable({
    ajax: 'data.json'
});

table.ajax.url('newData.json').load();

对于DataTables 1.9

使用fnReloadAjax()插件从Ajax源重新加载表的数据。请注意,该插件已被弃用。

本文地址:http://jquery.askforanswer.com/jishigenggaishezhizhi.html
文章标签: ,  
版权声明:本文为原创文章,版权归 admin 所有,欢迎分享本文,转载请保留出处!

文件下载

老薛主机终身7折优惠码boke112

上一篇:
下一篇:

评论已关闭!