dataTable 点击行弹窗

来源:互联网 发布:论坛抢沙发软件 编辑:程序博客网 时间:2024/06/03 07:40
QuestionJobCodedataTables = $('#datatable').DataTable({           "createdRow": function(row, data, index) {                   $(this, row).attr('data-toggle', 'modal').attr('data-target', '.bs-example-modal-sm1');               },           "bSort": false,               ajax: {                   type: 'POST',                   url: '/reportyJobInfo/getErrorJobInfo',                   async: false,                   dataSrc: "",                   data: function(data) {                       var getquestionJobCodeTime = document.getElementById("getTimesQuestionJobCode").innerHTML;                       var t0 = getquestionJobCodeTime.substring(0, 19);                       var t1 = getquestionJobCodeTime.substring(22);                       data.t0 = t0,                       data.t1 = t1                   }               },               columnDefs: [               {                   targets: 0,                   width: '15%',                   data: [0]               },               {                   targets: 1,                   width: '65%',                   data: [1]               },                {                   targets: 2,                   width: '20%',                   data: [2]               },               ],               language: {    "sProcessing": $.i18n.prop('处理中...'),    "sLengthMenu": $.i18n.prop('显示 _MENU_ 台结果'),    "sZeroRecords":$.i18n.prop('没有匹配结果'),    "sInfo":$.i18n.prop('显示第 _START_ 至 _END_ 台,共 _TOTAL_ 台'),    "sInfoEmpty": $.i18n.prop('显示第 0 至 0 台结果,共 0 台'),    "sInfoFiltered":$.i18n.prop('(由 _MAX_ 台结果过滤)'),    "sInfoPostFix": "",    "sSearch": $.i18n.prop('查询'),    "sUrl": "",    "sEmptyTable":$.i18n.prop('数据为空'),    "sLoadingRecords":$.i18n.prop('载入中...'),    "sInfoThousands": ",",    "oPaginate": {    "sFirst":$.i18n.prop('首页'),    "sPrevious":$.i18n.prop('上页'),    "sNext":$.i18n.prop('下页'),    "sLast":$.i18n.prop('末页')    },    "oAria": {    "sSortAscending":$.i18n.prop('以升序排列此列'),    "sSortDescending":$.i18n.prop('以降序排列此列')    }    }           });       });
 $('#datatable tbody').on('click', 'tr',function() {                      var data = QuestionJobCodedataTables.row(this).data();              alert(data[2])                 });  
 <table class="table" id="datatable">                        <thead>                            <tr class="headings">                                <th class="column-title">                                    <label data-locale="i18n_jobCode"></label>                                </th>                                <th class="column-title">                                    <label data-locale="i18n_question"></label>                                </th>                                <th class="column-title">                                    <label data-locale="i18n_remark"></label>                                </th>                            </tr>                        </thead>                        <tbody id="table22">                        </tbody>                    </table>



原创粉丝点击