zoukankan      html  css  js  c++  java
  • angular JS中使用jquery datatable添加checkbox点击事件

    'use strict';
    
    app.controller('DataTableCtrl', function ($scope, $compile) {
        $scope.selected = [];
        
        $scope.isSelected = function (obj,index, id) {
            var checkbox = obj.target;
           
            checkbox.checked ? $scope.selected.push(id) : $scope.selected.splice(index,1);
            console.log($scope.selected);
        }
        $scope.simpleTableOptions = {
            sAjaxSource: '/Home/Index',
            "sServerMethod": "POST",
            "bProcessing": true,
            "bServerSide": true,
            "bPaginate": true,
            aoColumns: [
                {
                    data: 'id', 'bSortable': false, "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                       
                    $(nTd).html('<input type="checkbox"   ng-click="isSelected($event,' + iRow + ',' + oData.id + ')">');
                    $compile(nTd)($scope);
                }},
                { data: 'id' },
                { data: 'title' },
                {
                    data: 'add_time'
                }
             
            ],
            "sDom": "Tflt<'row DTTTFooter'<'col-sm-6'i><'col-sm-6'p>>",
            "iDisplayLength": 10,
            "oTableTools": {
                "aButtons": [
                    "copy", "csv", "xls", "pdf", "print"
                ],
                "sSwfPath": "assets/swf/copy_csv_xls_pdf.swf"
            },
            "language": {
                "search": "",
                "sLengthMenu": "_MENU_",
                "oPaginate": {
                    "sPrevious": "上一页",
                    "sNext": "下一页"
                }
            },
            "aaSorting": [],
    
           
        };
    });
    

      

  • 相关阅读:
    DB2完美卸载
    protobuf2.5 iphone5s中崩溃的问题
    由fprintf和printf看C语言三种标准流
    AIR加载PDF
    使用二叉堆实现优先队列
    11636
    apache archiva安装教程
    WP独立文件资源字典
    常用软件架构模式(收集)
    MATLAB——单层感知器
  • 原文地址:https://www.cnblogs.com/lkd3063601/p/5406490.html
Copyright © 2011-2022 走看看