Javascript Codeigniter-在搜索和分页时,不会保留来自复选框的jQuery Datatables选中值
我遇到了一个问题,在从不同页面的jquery数据表中选择多个成员时,如果我从第一个页面选择2个成员,从第二个页面选择2个成员,当我返回第一个页面时,值复选框没有勾选,返回第二个页面时,值复选框相同。在数据表中搜索时也会发生同样的情况。可能是什么问题?我将在下面发布我的控制器、模型、视图和Datatable JS: 视图: DATATABLE JS: 这几乎就是我用过的代码,有人能帮我一下吗?谢谢。试试这个Javascript Codeigniter-在搜索和分页时,不会保留来自复选框的jQuery Datatables选中值,javascript,php,jquery,codeigniter,datatable,Javascript,Php,Jquery,Codeigniter,Datatable,我遇到了一个问题,在从不同页面的jquery数据表中选择多个成员时,如果我从第一个页面选择2个成员,从第二个页面选择2个成员,当我返回第一个页面时,值复选框没有勾选,返回第二个页面时,值复选框相同。在数据表中搜索时也会发生同样的情况。可能是什么问题?我将在下面发布我的控制器、模型、视图和Datatable JS: 视图: DATATABLE JS: 这几乎就是我用过的代码,有人能帮我一下吗?谢谢。试试这个 $('input[type=checkbox]').each(function () {
$('input[type=checkbox]').each(function () {
newvalue = ( $(this).val());
if (this.checked) {
do your code
}
do what you want
});
它应该只保留搜索时的值,并通过不同的页面检查google这个datatables在整个页面中保留检查值,一堆提示弹出,这个答案的可能副本甚至有一个JSFIDLE:谢谢Vickel,我将研究这些:嗨Vickel,值被保留,而bServerSide:false,但它只显示2000个条目中的100个条目
$tmpl = array ( 'table_open' => '<table id="big_table" border="1" cellpadding="2" cellspacing="1" class="table table-striped">' );
$this->table->set_template($tmpl);
$this->table->set_heading('<input type="checkbox" id="selAll" name="select_all" />','Customer Name','Email','Phone');
public function list_customers($center_id ='',$course_id =''){
$this->datatables->select("customer_id, CONCAT_WS( ' ' , firstname , lastname ) as firstname, email ,phone")->where('is_disable',0)
->edit_column('customer_id', input_checkbox('customer_id[]' ,'$1' ),'customer_id')->from($this->_table_name);
if(!empty($center_id)) $this->db->where('category',$center_id);
if(!empty($course_id)){
$this->db->where('customer_id IN (select customer_id from `dance_customer_course` WHERE dance_customer_course.`festival_id` = '.$course_id.')');
}
return $this->datatables->generate();
}
<script type="text/javascript">
$(document).ready(function() {
$("#sform").submit(function(){
if($('.checkbox:checked').length < 1){
alert("Please select the customer");
return false
}
if($('#content').val() == ''){
alert("Please enter content");
return false
}
});
var oTable = $('#big_table').dataTable( {
"bProcessing": true,
"bInfo": false,
"bServerSide": true,
"sAjaxSource": '<?php echo base_url(); ?>sendsms/list_customers',
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"iDisplayStart ":20,
"oLanguage": {
"sProcessing": "<img src='<?php echo base_url(); ?>img/ajax-loader.gif'>"
},
"fnInitComplete": function() {
//oTable.fnAdjustColumnSizing();
},
'fnServerData': function(sSource, aoData, fnCallback)
{
$.ajax
({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
});
}
});
$('#selAll').click(function(e){
if (e.stopPropagation) e.stopPropagation();
var checkBoxes = $(".checkbox");
if(checkBoxes.prop("checked")) $(this).text("Check All");
else $(this).text("Uncheck All");
checkBoxes.prop("checked", !checkBoxes.prop("checked"));
});
});
$('input[type=checkbox]').each(function () {
newvalue = ( $(this).val());
if (this.checked) {
do your code
}
do what you want
});