如何在 Jquery DataTable 中添加按钮
How to add button in Jquery DataTable
我的数据表脚本如下所示
var getsourcinglist = function (url){
$('#ajaxLoader').show();
$.ajax({
type : 'GET',
url : url,
beforeSend : function() {
console.log('sending request to fetch');
},
success : function(data) {
$('#ajaxLoader').hide();
printTheSourcinglistview(data);
},
error: function(data){
$('#ajaxLoader').hide();
console.log(data);
}
});
}
var printTheSourcinglistview = function(data){
var trHTML = "" ;
var table = $('#dataTable1').dataTable({
"bProcessing": true,
aaData: data,
buttons: [
'copy', 'excel', 'pdf'
],
"aoColumns": [
{ "mData": "rrno" },
{ "mData": "name" },
{ "mData": "dob" },
{ "mData": "gender" },
{ "mData": "job_profile" },
{ "mData": "graduation" },
{ "mData": "total_exp" },
{ "mData": "phone" },
{ "mData": "salary_drawn" },
{ "mData": "salary_expected" },
{ "mData": "email" },
{ "mData": "status" },
{ "mData": "<button id="x">Click!</button>" },
],
});
table.buttons( 'output:name', '.export' ).enable();
console.log(table);
}
HTML 表在这里
<table id="dataTable1" class="table table-bordered table-striped-col">
<thead>
<tr>
<th>Sourcing ID</th>
<th>Name</th>
<th>Dob</th>
<th>Gender</th>
<th>Job Profile</th>
<th>Basic / Graduation</th>
<th>Total Exp</th>
<th>Contact</th>
<th>Salary Drawn</th>
<th>Salary Expected</th>
<th>Final Status</th>
<th>Email</th>
<th>Action</th>
</tr>
</thead>
</table>
我收到一个错误,指出按钮 HTML 无法识别。
任何帮助
谢谢
取而代之的是:
{ "mData": "<button id="x">Click!</button>" },
做
{ mDataProp: null, bSortable: false, bSearchable: false, mRender: createBtn },
现在添加createBtn
函数,如下所示:-
function createBtn(oObj) {
return '<button class="x">Click!</button>';
}
以及委托的单击事件处理程序,如下所示:
$(document).on('click', '.x', function (e) {
alert('Button clicked!');
});
相关文章:
- 在HTML5画布上添加按钮和控件
- 无法在图像周围添加按钮
- Sitecore富文本编辑器-添加按钮
- 如何在标记href中添加按钮
- jqgridnavgrid在搜索按钮和自定义按钮之后添加按钮
- 如何在视频标签中添加按钮覆盖
- 添加按钮以切换浏览器
- 如何在php中添加按钮而不是错误状态和成功消息
- Struts2jquery可编辑网格,要禁用内联添加按钮
- 如何在服务器端的文本中添加按钮单击事件
- 简单的dart网页应用程序在IE上添加按钮的速度非常慢
- 向HTML页面添加按钮,更新表格信息
- (PHP&JavaScript)a href添加按钮赢得'我不适用于Mozilla,但适用于IE和谷歌
- 单击添加按钮后如何显示答案按钮
- 如何在 extjs 5 中的工具提示中添加按钮
- 在数据表的新行中添加按钮,变得未定义
- 如何向照片滑动添加按钮
- 动态添加按钮后刷新 jQm 标头
- PHP,MySql和JQuery - 按添加按钮后填充选择框
- 动态添加按钮,这些按钮也会动态添加文本框 AngularJS