Editor Bubble Checkbox Order Descending?
Editor Bubble Checkbox Order Descending?
Hi Allen and Everyone,
I've been digging through the docs and I can't seem to find any way to set bubble checkboxes to descending order.
I have used an Mjoin to bring in data from another table using a link table. This works fine and dandy. I can also set a bubble edit for this field and set the edit type for the field to checkbox and get a nice list of checkboxes that will update the link table appropriately. Further, I can set ->order('FieldName desc') on the backend and the display of the data will be descending in the table.
However, I must be missing something because after digging and digging through the docs I cannot find a way using render, columnDefs or otherwise to force the Bubble edit to list these Mjoin checkboxes in descending order.
Relevant Code:
HTML
<table id="table" class="display">
<thead>
<tr>
<th>Issues</th>
</tr>
</thead>
</table>
PHP
->join(
Mjoin::inst( 'issues' )
->link( 'table.id', 'link_table.id' )
->link( 'issues.issueID', 'link_table.issueID' )
->order( 'issueCode desc' ) // Ex. 45/3 or 43/1
->fields(
Field::inst( 'issueID' )
->options( 'issues', 'issueID', 'issueCode' )
->validator( 'Validate::none' ),
Field::inst( 'issueCode' )
)
)
JS
editor = new $.fn.dataTable.Editor( {
ajax: "php/server_processing.php",
table: "#table",
fields: [
{
label: "Issues:",
name: "issues[].issueID",
type: "checkbox"
}
]
} );
table = $('#adminTable').DataTable( {
columns: [
{ data: "issues",
render: function ( data, type, full ) {
return $.map( data, function ( d, i ) {
return d.issueCode;
} ).join( ', ' );
},
editField: "issues[].issueID"
}
]
});
$('#table').on( 'click', 'tbody td:not(:first-child)', function (e) {
editor.bubble( this, {
title: 'Issues',
message: 'All the issues for this contact.'
} );
}
Thanks Allen!
Harbor House Publishers
Answers
Hi,
Rather than using
->options( 'issues', 'issueID', 'issueCode' )
, use the newOptions
class that is in Editor 1.6 and provides a method to specify ordering for the options:Regards,
Allan
Thank you, Allan,
It works!
I had previously tried this thinking I was on Editor 1.6 because I had updated the Datatables core, and the Editor folder there was on 1.6, however I hadn't updated the PHP Editor core and I'm using an AJAX datasource, so I kept getting errors when I tried to use the new Options class.
One note, just for anybody that stumbles on this (that I found on some random thread) is to include the DataTables\Editor\Options line in the Alias section of your PHP processing file. That tripped me up as well for a bit.
But all's well that ends well as they say.
Thanks again!