problem with checkbox sorting

problem with checkbox sorting

yahyaEyahyaE Posts: 4Questions: 0Answers: 0
edited April 2012 in DataTables 1.9
Hi,

First is first and sorry for long question.

**Modal**
[code]
function fetch_products()
{
$sql_previewable = "
SELECT a.stockID, a.stockName, a.stockCode, a.stockCatCode
FROM stockcards a "; // I will tell the reason why this is here

$sql = "
SELECT a.stockID, a.stockCatID, a.stockName, a.stockCode, a.stockCatCode,
CONCAT_WS(' » ', d.stockCatName, c.stockCatName, b.stockCatName) AS stockPath
FROM stockcards a
LEFT OUTER JOIN stockcategories b
ON a.stockCatID = b.stockCatID
LEFT OUTER JOIN stockcategories c
ON b.stockParentCat = c.stockCatID
LEFT OUTER JOIN stockcategories d
ON c.stockParentCat = d.stockCatID ";

$query = $this->db->query($sql);

if($query->num_rows() > 0)
{
$res = $query->result_array();
foreach ($res as $v)
{
$tmp['aaData'][] = $v;
}

$data = $tmp;
return $data;
}
}
[/code]
**Controller**

[code]
function fetch_products()
{
if($this->input->is_ajax_request())
{
$r = $this->apm->fetch_products();
$this->output->set_content_type('application/json');
$this->output->set_output(json_encode($r));
}
else
{
show_404();
}
}[/code]

and finally **View**

[code]
var mod_name = '<?=$mod_name;?>';
oTable = $('#dataTable').dataTable({
"bProcessing": true,
"bDeferRender": true,
"bJQueryUI": true,
"iDisplayLength": 10,
"iDeferLoading": 20,
"aaSorting": [],
"sPaginationType": "full_numbers",
"sServerMethod": "POST",
"sAjaxSource": base_url+'ajax_ops/fetch_products',
"aoColumns":
[
{ "mDataProp": "stockID", "sTitle": "No", "sWidth": "05%", "bVisible":false },
{ "mDataProp": "stockName", "sTitle": "Stok Kartı", "sWidth": "30%", "fnRender":
function (oObj) {
return ''+oObj.aData.stockName+"";
}
},
{ "mDataProp": "stockPath", "sTitle": "Kategori Referansı", "sWidth": "30%", "sClass": "data-small" },
{ "mDataProp": "stockCatCode", "sTitle": "Cat", "sWidth": "15%", "sClass": "center", "bVisible":false },

{ "mDataProp": "stockCode", "sTitle": "Kodu", "sWidth": "10%", "sClass": "center", "fnRender":
function (oObj) {
return oObj.aData.stockCatCode[0]+oObj.aData.stockCatCode[1]+
'.'+oObj.aData.stockCatCode[2]+oObj.aData.stockCatCode[3]+
'.'+oObj.aData.stockCatCode[4]+oObj.aData.stockCatCode[5]+
'.'+oObj.aData.stockCode;
}
},
{ "mDataProp": "stockID", "sTitle": "Ekle", "sWidth": "5%", "sClass": "center", "fnRender":
function (oObj) {
return '';
}
},
],
});[/code]

Table loads succesfully on cross-browser, however can't see the json preview in chrome inspection. But IE and firebug, it can previewed, it is ok. If I fire `sql_previewable`
query to function, chrome also preview json data.

Sample line of json:

[code] {"aaData":[{"stockID":"1","stockCatID":"4","stockName":"\u0130-100 Yan Kilit","stockCode":"0001","stockCatCode":"000301","stockPath":"Bitmi\u015f \u00dcr\u00fcnler \u00bb Kilitler"},[/code]


Anyway the **problem** is I can't sort checkbox column based on it check or not.

With below script, I can access all signed as checked through the pages(means no problem with pagination)

[code]$('#update_cart').click(function(e) {
e.preventDefault();
checked_boxes = oTable.$('input').serialize();
var exploded = checked_boxes.split('&');
$('#checkedBoxes').val(exploded);
return false;
});[/code]

But, yet again, I can't make the sorting [code]Ekle[/code] column that contains checkboxes.

I am stucked, any help will be appreciated. Thank you.

Replies

  • yahyaEyahyaE Posts: 4Questions: 0Answers: 0
    Note: When I added it as the first column with dom-live api, it works. But if I move it to the last column it says 'unknown parameter error' and in the console 'Cannot call method 'replace' of null'
This discussion has been closed.