У меня проблемы с передачей данных в мою модель. Все работает, пока я не получу более 9 переменных. Чего мне не хватает? Данные передаются до sugg_stock="$9"
, но все, что я пытаюсь передать после $9
, не работает. Так что data-"x"="$10"
не работает.
Код проблемы является частью моей модели:
$this->datatables->add_column('view', '<a href="javascript:void(0);" class="edit_record btn btn-info" data-code="$1" data-name="$2" data-price="$3" data-department="$4" data-cost="$6" data-qoh="$7" data-reorder="$8" data-sugg_stock="$9" data-product_tax="$10" data->Edit</a>','product_code,product_name,product_price,department_id,department_name,product_cost,product_qoh,product_reorder,product_sugg_stock,tax_id,rate');
Вот моя модель:
//generate dataTable serverside method
function get_all_product() {
$this->datatables->select('product_code,product_name,product_price,department_id,department_name,product_cost,product_qoh,product_reorder,product_sugg_stock,tax_id,rate');
$this->datatables->from('product');
$this->datatables->join('departments', 'product_department_id=department_id');
$this->datatables->join('tax_rates','product_tax_id=tax_id');
$this->datatables->add_column('view', '<a href="javascript:void(0);" class="edit_record btn btn-info" data-code="$1" data-name="$2" data-price="$3" data-department="$4" data-cost="$6" data-qoh="$7" data-reorder="$8" data-sugg_stock="$9" data-product_tax="$10" data->Edit</a>','product_code,product_name,product_price,department_id,department_name,product_cost,product_qoh,product_reorder,product_sugg_stock,tax_id,rate');
return $this->datatables->generate();
Вот мой взгляд:
<script>
$(document).ready(function(){
// Setup datatables
$.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings)
{
return {
"iStart": oSettings._iDisplayStart,
"iEnd": oSettings.fnDisplayEnd(),
"iLength": oSettings._iDisplayLength,
"iTotal": oSettings.fnRecordsTotal(),
"iFilteredTotal": oSettings.fnRecordsDisplay(),
"iPage": Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength),
"iTotalPages": Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)
};
};
var table = $("#mytable").dataTable({
initComplete: function() {
var api = this.api();
$('#mytable_filter input')
.off('.DT')
.on('input.DT', function() {
api.search(this.value).draw();
});
},
oLanguage: {
sProcessing: "loading..."
},
processing: true,
serverSide: true,
ajax: {"url": "<?php echo base_url().'index.php/crud/get_product_json'?>", "type": "POST"},
columns: [
{"data": "product_code"},
{"data": "product_name"},
{"data": "department_name"},
{"data": "product_cost"},
//render number format for price
{"data": "product_price"}, //render: $.fn.dataTable.render.number(',', '.', '')},
{"data": "product_qoh"},
{"data": "product_reorder"},
{"data": "product_sugg_stock"},
{"data": "rate"},
{"data": "view"}
],
order: [[1, 'asc']],
rowCallback: function(row, data, iDisplayIndex) {
var info = this.fnPagingInfo();
var page = info.iPage;
var length = info.iLength;
$('td:eq(0)', row).html();
}
});
// end setup datatables
// get Edit Records
$('#mytable').on('click','.edit_record',function(){
var code=$(this).data('code');
var name=$(this).data('name');
var cost=$(this).data('cost');
var price=$(this).data('price');
var department=$(this).data('department');
var qoh=$(this).data('qoh');
var reorder=$(this).data('reorder');
var sugg_stock=$(this).data('sugg_stock');
var product_tax=$(this).data('product_tax');
$('#ModalUpdate').modal('show');
$('[name="product_code"]').val(code);
$('[name="product_name"]').val(name);
$('[name="price"]').val(price);
$('[name="department"]').val(department);
$('[name="cost"]').val(cost);
$('[name="qoh"]').val(qoh);
$('[name="reorder"]').val(reorder);
$('[name="sugg_stock"]').val(sugg_stock);
$('[name="product_tax"]').val(product_tax);
});
// End Edit Records
// get delete Records
$('#mytable').on('click','.delete_record',function(){
var code=$(this).data('code');
$('#ModalDelete').modal('show');
$('[name="product_code"]').val(code);
});
// End delete Records
});