Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JQuery datatable with ajax, post API call hook

$(async function() {
    $('#registry_table').DataTable({
        serverSide: true,
        ajax: {
            url: 'localhost:3000/provenance/registries',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': 'Bearer ' + localStorage.getItem("token")
            },
            data: () => {
               return {page: 0, per_page: 5};
            }
        },
        columns: [
            {data: 'name', defaultContent: 'N/A'},
            {data: 'created', defaultContent: 'N/A'},
            {data: 'extrinsic', defaultContent: 'N/A'},
            {data: 'registry', defaultContent: ' <span class="text-primary bg-white fa-border d-inline-block" style="cursor: pointer" title="Rename Registry"><i class="fas fa-pen-nib"/> Rename</span>'}
        ],
        language: {
            searchPlaceholder: "Search...",
            search: "",
            lengthMenu: "_MENU_ &nbsp;items/page"
        }
    });
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #JQuery #datatable #post #API #call #hook
ADD COMMENT
Topic
Name
8+2 =