禁用dataTable的某些行中的选定行

时间:2017-01-10 05:58:40

标签: javascript datatables jquery-ui-selectable

我使用DataTable创建列表。我无法在其中选择多行。 单击某些第一行(表的第1页)时,选择了行。但是当点击其他页面时,没有选择行,也没有去过这个脚本,也没有显示任何内容:

 $("#example tbody tr").click( function( e ) {

                            console.log(e);
                            console.log( $(this).hasClass('selected'));

                            if ( $(this).hasClass('selected') ) {
                                console.log(1111111111);
                                $(this).removeClass('selected');
                            }
                            else {
                                console.log(222222222);
                                table.$('tr.selected')//.removeClass('selected');
                                $(this).addClass('selected');
                            }
                        }); 

我的桌子:

 Studentjson = {BrowserStats};

                        var data = jQuery.map(Studentjson.BrowserStats, function (el, i) {
                            return [[el.imagePath, el.firstName, el.lastName, el.homeLocationText, el.homePhoneNumber,
                                el.role, el.edit, el.delete]];
                        });

                              table = $('#example').DataTable({
                            "aaData": data,
                            columns: [
                                {
                                    "width": "3%",
                                    data: null,
                                    className: "center",
                                    "orderable": false,
                                    defaultContent: '<img class="img-responsive"  src="" />'
                                },
                                {"width": "27%"},
                                {"width": "27%"},
                                {"width": "37%"},
                                {
                                    data: null,
                                    "width": "3%",
                                    className: "center",
                                    "orderable": false,
                                    defaultContent: '<p data-placement="top" data-toggle="tooltip" title="Edit"><button id="EditStudent" class="btn btn-primary btn-xs" data-title="ویرایش"  ><span class="glyphicon glyphicon-pencil"></span></button></p></td>'
                                },
                                {
                                    data: null,
                                    "width": "3%",
                                    "orderable": false,
                                    defaultContent: '<p  data-placement="top" data-toggle="tooltip" title="Delete"><button id="DeleteStudent" class="btn btn-danger btn-xs" data-title="Delete"  ><span class="glyphicon glyphicon-trash"></span></button></p>'
                                },
                                {

                                    "visible": false,
                                    "searchable": false
                                },
                                {

                                    "visible": false,
                                    "searchable": false
                                }
                            ]
                        });

为什么会这样?我应该做什么?

0 个答案:

没有答案