Home Forums Porto Admin Template Data Tables Always do ASC

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #10030034
    riandy
    Participant

    I’m using datatable-default. I’ve checked my database query, it returned in DESC position. But, when it come to datatable, it’s always in ASC position.

    Is there any ways to not automatically ordered my datatable? Thanks.



    Template Version: -
    #10030040
    Support2
    Keymaster

    Hello,

    You can change the order/sort of dataTable with the option order:

    (js/examples/examples.datatables.default.js):

    (function($) {
    
    	'use strict';
    
    	var datatableInit = function() {
    
    		$('#datatable-default').dataTable({
    			dom: '<"row"<"col-lg-6"l><"col-lg-6"f>><"table-responsive"t>p',
    			order: [[2, 'desc']]
    		});
    
    	};
    
    	$(function() {
    		datatableInit();
    	});
    
    }).apply(this, [jQuery]);

    * This code will order in DESC using as base the values on third column.

    Please, try that and let us know if you need further assistance.

    Kind Regards,

    Rodrigo.


    #10030052
    riandy
    Participant

    The code is work. But, Can I put my data from my query into datatable without editing JS Script?


    #10030055
    Support2
    Keymaster

    Hello,

    No. If you will use a DataTable will be necessary define the order on JS code.

    If the order is a dynamic setting, our suggestion for your is put the JS code as internal script on footer of page. For example:

    In that way you can print a server side code to change the desc value.

    Hope this helps.

    Kind Regards,

    Rodrigo.


Viewing 4 posts - 1 through 4 (of 4 total)