Select plug in

Select plug in

Diego1966Diego1966 Posts: 20Questions: 4Answers: 0

good evening everyone, I would like some information please, is it possible in the SElect plugin to enable and display only the row information and disable and not make the information on the column and cell visible?
if it were possible how?
Would you be so kind as to explain it? I tried with:
items:'columns',
info:false
items:'cell'
info: false
but it doesn't work and I didn't find information on how to disable by choosing what:

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,292Questions: 26Answers: 4,944
    edited April 16

    Do you mean to disable the selected info display when select by cells, like this example?
    https://live.datatables.net/mocerasi/1/edit

    Can you post a test case showing the issue you are having so we can help debug?
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • Diego1966Diego1966 Posts: 20Questions: 4Answers: 0

    I meant if it was possible to display only the information when selecting the row, normally the complete information that is returned when a row is selected is: "1 row selected - 0 columns selected - 0 cells selected", I wanted to know if it was possible not display the information about the columns and cells and only that of the row remains, so instead of "1 row selected - 0 columns selected - 0 cells selected", I wanted to know if it was possible to obtain only "1 row selected".

  • kthorngrenkthorngren Posts: 21,292Questions: 26Answers: 4,944

    Sounds like you might have language.select configured to display language.select.cells, language.select.columns and language.select.rows. Is this the case? If it is do you use cells and columns select modes?

    It would probably help if you at least posted your full Datatables config so we understand what you have.

    Kevin

  • Diego1966Diego1966 Posts: 20Questions: 4Answers: 0

    you're right, place the configuration of the DataTables in the JS file:

    $(document).ready(function () {
        var tableDipendenti = $("#tableDipendenti").DataTable({
            ajax: {
                url: "../php/dipendente.php",
                dataSrc: "data",
            },
            columns: [
                {
                    className: "details-control",
                    orderable: false,
                    data: null,
                    defaultContent: '<i class="fas fa-plus-circle"></i>',
                    width: "5%",
                },
                { data: "iddip", visible: false },
                { data: "matr" },
                { data: "cognome" },
                { data: "nome" },
                { data: "nascita" },
                { data: "matrcomune" },
                { data: "assunzione" },
                { data: "iniznomin" },
                {
                    data: "foto",
                    render: function (data) {
                        return '<img src="' + data + '" alt="Immagine dipendente" style="width:50px;height:50px;">';
                    },
                },
                { data: "stato" },
                { data: "totbadge" },
            ],
            select: {
                style: 'single',
               items:'row',
                info: false
            },
            lengthMenu: [5, 10],
            order: [[2, "asc"]],
            language: {
                url: "../json/italiano.json",
            }
        });
    
        $('#tableDipendenti tbody').on('click', 'td.details-control', function() {
            var tr = $(this).closest('tr');
            var row = tableDipendenti.row(tr);
            var icon = $(this).find('i');
    
            if (row.child.isShown()) {
                row.child.hide();
                tr.removeClass('shown');
                icon.removeClass('fa-minus-circle').addClass('fa-plus-circle').css('color', 'green');
            } else {
                var iddip = row.data().iddip;
                formatBadgeDetails(row, iddip);
                tr.addClass('shown');
                icon.removeClass('fa-plus-circle').addClass('fa-minus-circle').css('color', 'red');
            }
        });
    
        function formatBadgeDetails(row, iddip) {
            var subTableId = 'details-' + iddip;
            var detailsFooterId = 'badgeDetailsFooter-' + iddip;
            var html = '<table id="' + subTableId + '" class="display" style="width:100%;">' +
                '<thead>' +
                '<tr>' +
                '<th>ID Badge</th>' +
                '<th>ID Dipendente</th>' +
                '<th>Numero Badge</th>' +
                '<th>Striscia Magnetica</th>' +
                '<th>NFC</th>' +
                '<th>Richiesto</th>' +
                '<th>Rilascio</th>' +
                '<th>Causale</th>' +
                '<th>Rilascio Per</th>' +
                '<th>Foto</th>' +
                '</tr>' +
                '</thead></table>' +
                '<div id="' + detailsFooterId + '"></div>';
    
            row.child(html).show();
    
            var badgeTable = $('#' + subTableId).DataTable({
                ajax: {
                    url: '../php/badgecount.php',
                    type: 'POST',
                    data: { iddip: iddip },
                    dataSrc: 'data'
                },
                columns: [
                    { data: 'idbadge', visible: false },
                    { data: 'iddip', visible: false },
                    { data: 'nbadge' },
                    { data: 'strmagn' },
                    { data: 'nfc' },
                    { data: 'richiesto' },
                    { data: 'rilascio' },
                    { data: 'causale' },
                    { data: 'rilascioper' },
                    { data: 'foto' }
                ],
                select: {
                    style: 'single',
                   items:'row',
                    info: false
                },
                pageLength: 5,
                ordering: true,
                order: [[0, "desc"]],
                searching: false,
                paging: true,
                lengthChange: false,
                language: {
                    url: "../json/ita.json"
                },
                drawCallback: function (settings) {
                    var api = this.api();
                    var jsonData = api.ajax.json(); // Ottiene la risposta JSON
                    if (jsonData && jsonData.dettaglioBadge) {
                        $('#' + detailsFooterId).html(jsonData.dettaglioBadge);
                    } else {
                        $('#' + detailsFooterId).html("Dettagli non disponibili.");
                    }
                }
            }).on('select', function (e, dt, type, indexes) {
                var badgeData = dt.row({ selected: true }).data();
                alert('ID Badge selezionato: ' + badgeData.idbadge);
            });
        }
    });
    
    

    I hope I have expressed myself clearly, I repeat, I just need that when selecting the row the info at the bottom only returns to me that I have selected the row, I don't care that it informs me that columns and cells are 0, and therefore have not been select

  • kthorngrenkthorngren Posts: 21,292Questions: 26Answers: 4,944

    I just need that when selecting the row the info at the bottom only returns to me that I have selected the row,

    You have this:

            select: {
                style: 'single',
               items:'row',
                info: false
            },
    

    Remove the info: false and you should see the number of selected rows. I copied that code snippet into this test case with info: false commented out. It only shows the number of rows selected.
    https://live.datatables.net/mocerasi/3/edit

    If you see different behavior them please provide a test case showing the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • allanallan Posts: 63,439Questions: 1Answers: 10,459 Site admin
    Answer ✓

    To dip my oar in as well, I think you'll need to modify your ../json/ita.json file a little. Change the language.select.cells and language.select.columns properties to have an empty string for the 0 property

    Allan

  • Diego1966Diego1966 Posts: 20Questions: 4Answers: 0
     ],
            select: {               //first table
                style: 'single',
               items:'row',
                //info: false
            },
            lengthMenu: [5, 10],
            order: [[2, "asc"]],
            language: {
                url: "../json/italiano.json",
            }
        });```
    
    
    ``` select: {               // second table
                    style: 'single',
                   items:'row',
                    //info: false
                },
    

    nothing to do even commenting info, the references to the rows and columns remain

  • Diego1966Diego1966 Posts: 20Questions: 4Answers: 0

    thank you Allan

Sign In or Register to comment.