Charge data after N° time

Charge data after N° time

prox108prox108 Posts: 27Questions: 12Answers: 0

Hi guys,
I am loading data on a Datable that takes less than a second in charge.
Do you know if datatable have a propiety where you can define how many time has to happend after it load data on the datable?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I don't understand your question. You say that loading the data for the table takes less than a second? But I don't know what you mean by defining time? Do you mean you want something to happen after it has loaded? If so, use ready().

    Allan

  • prox108prox108 Posts: 27Questions: 12Answers: 0

    What I want is to add more time before it loads, to see the default charging message of the datatable

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951
    Answer ✓

    Sounds like you want to display the processing spinner for a short time and that the time to load the data is too short to see the spinner. Is this correct?

    There isn't anything built in to delay Datatables loading the data. Most people want the data loaded without any delay :smile:

    To provide suggestions we will need to understand how you are loading the data, ie, HTML sourced table, ajax, jQuery ajax(), data, etc. Please post your Datatables init code and any relevant data loading code.

    One option, depending on your config, is to use the processing() API.

    Kevin

  • prox108prox108 Posts: 27Questions: 12Answers: 0
    edited September 12

    Thanks, that is what I wanted to know!

    Here is an example:

    let tb1 = $('#tb1').DataTable({
            'searching': false,
            'paging': false,
            'order': false,
            'buttons': [],
            //'serverSide': true,
            //'async': true,
            'processing': true,
            "info":false,
            ajax: {
                url: 'c/d/ajax.get.php',
                type: 'post',
                dataType: 'json',
                data: {idUser: v_idUser}
            },
            'columns': [
                {data: 'est_descripcion', className: 'text-center', 'width': '25%', 'orderable': false}, // Establecimiento
                {data: 'marcacion', className: 'text-center', 'width': '25%', 'orderable': false}, // Fecha
                {data: 'fecha_hora', className: 'text-center', 'width': '25%', 'orderable': false}] // Hora
        });
    
    $('#btn').on('click', function () {
            $('#btn').attr('disabled','disabled');
            tb1.clear().draw().ajax.reload();
            $('#btn').removeAttr('disabled');
        });
    

    Data:

    {"data":[
    {"est_descripcion":"H","fecha":"12-09-2024","hora":"09:42:31","ses_ip":"a"},{"est_descripcion":"H","fecha":"12-09-2024","hora":"09:02:54","ses_ip":"b"},{"est_descripcion":"H","fecha":"12-09-2024","hora":"08:05:24","ses_ip":"c"}
    ]}
    

    Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951

    Thanks, that is what I wanted to know!

    Do you still have questions?

    Kevin

  • prox108prox108 Posts: 27Questions: 12Answers: 0

    No , thanks for the help.

Sign In or Register to comment.