Skip to content

Instantly share code, notes, and snippets.

@moxet
Created September 21, 2021 12:25
Show Gist options
  • Select an option

  • Save moxet/7e27a359785c8fcf05d80877115e6a94 to your computer and use it in GitHub Desktop.

Select an option

Save moxet/7e27a359785c8fcf05d80877115e6a94 to your computer and use it in GitHub Desktop.
Add DataTable features to Crocoblock Table Builder
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.11.2/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.11.2/datatables.min.js"></script>
<script>
jQuery(document).ready(function($) {
$('.jet-dynamic-table').DataTable();
});
</script>
@wisiagency

wisiagency commented Jan 17, 2023

Copy link
Copy Markdown

hi may i ask a question? how can i use index column like this?
https://datatables.net/examples/api/counter_columns.html
image
and how to make highlight entries by column?

@moxet

moxet commented Mar 6, 2023

Copy link
Copy Markdown
Author

@wisiagency use this code

<script> 
jQuery(document).ready(function($) { 
var t = $('.jet-dynamic-table').DataTable({
        columnDefs: [
            {
                searchable: false,
                orderable: false,
                targets: 0,
            },
        ],
        order: [[1, 'asc']],
    });
 
    t.on('order.dt search.dt', function () {
        let i = 1;
 
        t.cells(null, 0, { search: 'applied', order: 'applied' }).every(function (cell) {
            this.data(i++);
        });
    }).draw();
}); 
</script>

@FernandaWP

Copy link
Copy Markdown

How do I translate into Portuguese?

@moxet

moxet commented Sep 21, 2023

Copy link
Copy Markdown
Author

@webiq1759

Copy link
Copy Markdown

Hello Moxet, please help me, I've that youtube video over and over again, that applies to the above piece of code. the pagination is not working, the filtering is not also working.

I would really be grateful for your assistance.

@webiq1759

Copy link
Copy Markdown

Thank you for your assistance. Issue resolved.

@alexgauvin

Copy link
Copy Markdown

Hi, thanks for this. Really helpful.

I'm using JetEngine Tables builder to display CPT repeater fields data. Seems that I can't automatically order columns.
Is it possible to force a column in a specific order with these snippets ? I did try with Default ordering (sorting) but can't make this work. Thanks

@moxet

moxet commented Feb 23, 2024

Copy link
Copy Markdown
Author

@alexgauvin i guess i replied in youtube, you need to pass flat/raw data to datatable instead of template.

@alexgauvin

Copy link
Copy Markdown

@moxet Thanks, I wasn't sure you would respond on YT. Everything's working as expected.

@Jonathan1500

Copy link
Copy Markdown

Thank you for your assistance. Issue resolved.

Hello, whats Is the Solution?

@alexgauvin

Copy link
Copy Markdown

@Jonathan1500 Here's my snippet, if it can help :

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.11.2/datatables.min.css"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/2.0.0/js/dataTables.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.11.2/datatables.min.js"></script>

<script> 
jQuery(document).ready(function($) { 
    $('.jet-dynamic-table').DataTable( {
		order: [[0, 'desc']],
		info: false,
		paging: false,
		searching: false
	});
});    
</script>

With it, you can display or not some elements on the table.
And, with the order param, you can point which column will be automatically filtered and in what order.

@Jonathan1500

Copy link
Copy Markdown

@Jonathan1500 Here's my snippet, if it can help :

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.11.2/datatables.min.css"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/2.0.0/js/dataTables.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.11.2/datatables.min.js"></script>

<script> 
jQuery(document).ready(function($) { 
    $('.jet-dynamic-table').DataTable( {
		order: [[0, 'desc']],
		info: false,
		paging: false,
		searching: false
	});
});    
</script>

With it, you can display or not some elements on the table. And, with the order param, you can point which column will be automatically filtered and in what order.

You table Is with crocoblock?

@alexgauvin

Copy link
Copy Markdown

Data is created with JetEngin CPT, with a custom repeater field.
Data is then displayed with Tables builder provided by JetEngine as an addon plugin.
But I wasn't able to filter repeater data. With @moxet's tutorials i'm good to go.

@Jonathan1500

Copy link
Copy Markdown

Data is created with JetEngin CPT, with a custom repeater field. Data is then displayed with Tables builder provided by JetEngine as an addon plugin. But I wasn't able to filter repeater data. With @moxet's tutorials i'm good to go.

I use the same jetengine and table builder, but I have a problem that only shows me 10 post

@gurutto-manila

Copy link
Copy Markdown

Data is created with JetEngin CPT, with a custom repeater field. Data is then displayed with Tables builder provided by JetEngine as an addon plugin. But I wasn't able to filter repeater data. With @moxet's tutorials i'm good to go.

I use the same jetengine and table builder, but I have a problem that only shows me 10 post

check your query if you put offset that limiting to 10

@Jonathan1500

Jonathan1500 commented Apr 1, 2024

Copy link
Copy Markdown

Hello, i dont have limit in my query

@SamP-dgt

SamP-dgt commented Oct 2, 2025

Copy link
Copy Markdown

Please Crocoblock consider including this function into the core! Also, can anyone explain how to get those texts translated? I mean "Show", "Entries", "Search"...

@moxet

moxet commented Oct 5, 2025

Copy link
Copy Markdown
Author

@SamP-dgt Yes you can use translation
https://datatables.net/plug-ins/i18n/

@manikhossain2025

Copy link
Copy Markdown

Hello everyone, I need help with JetEngine REST API pagination.

I have a JetEngine Custom Post Type (completed-project), and I’m loading the data on another website using the REST endpoint:
https://mydomain.com/wp-json/wp/v2/completed-project

The data loads correctly, but I cannot get pagination or the “Load More” button to work with the Listing Grid.

The listing loads the first set of items, but clicking “Load More” does not fetch additional posts.

Can anyone suggest a video tutorial for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment