首页 > 其他 > 详细

datatables 添加title属性

时间:2020-01-16 14:33:18      阅读:115      评论:0      收藏:0      [点我收藏+]

datatables 添加title属性

使用 createdRowcolumns.createdCell options 来定义一个回调函数用于创建 TR and TD 元素时添加属性.

$('#example').dataTable( {
  'createdRow': function( row, data, dataIndex ) {
      $(row).attr('id', 'someID');
  },
  'columnDefs': [
      {
      'targets': 3,
      'createdCell':  function (td, cellData, rowData, row, col) {
        $(td).attr('id', 'otherID');
      }
    }
  ]
});

Example:给td元素添加title属性

columns: [{
    "sClass": "member",
    "data": "id",
    "render": function (data, type, full, meta) {
      return '<i class="check_icon check_false" data-value="' + data + '">';
    },
    "bSortable": false
  },
  {
    "data": "name",
    'createdCell':  function (td, cellData, rowData, row, col) {
      $(td).attr('title', cellData); 
    }
  },
  {
    "data": "email",
    'createdCell':  function (td, cellData, rowData, row, col) {
      $(td).attr('title', cellData); 
    }
  }
}]

datatables 添加title属性

原文:https://www.cnblogs.com/dragonir/p/12200345.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!