Disable parent click to hide child info : Responsive

Disable parent click to hide child info : Responsive

alamgiraalamgira Posts: 4Questions: 1Answers: 0
edited January 2016 in Free community support

I have a responsive datatable which shows child info when it loads up and I need to disable child toggle when parent is clicked. Is there any configuration that i can override or a workaround to do this?

I have this so far

var table = $('#LobbyTable').DataTable({           
        deferRender : true,
        scrollY: 450,
        scrollX: false,
        scroller:true,
        loadingIndicator : true,
        language: {
            search:"",
            searchPlaceholder:"Search Contest"
        },
        aaSorting: [],
        responsive: {
            details: {
                display: $.fn.dataTable.Responsive.display.childRowImmediate,
                type: ''

            }
        },
        select : {
            info : false
        }

    });


       $($.fn.dataTable.tables(true)).DataTable().columns.adjust().responsive.recalc();

Answers

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Just to check my understanding - you want to allow a single click to show the details, but disable the click from then hiding them?

    If so, there is no built in option for that. You could possibly use a custom display renderer (responsive.details.renderer) to do that, just add the logic to not hide the child row, but it wasn't designed to operate in that way.

    Allan

  • alamgiraalamgira Posts: 4Questions: 1Answers: 0

    display: $.fn.dataTable.Responsive.display.childRowImmediate, this function is already showing my child which is great. I dont want user to click parent row to expand/collapse child row. Is there any way that i can override the parent click or disable it completely?

  • alamgiraalamgira Posts: 4Questions: 1Answers: 0
    edited January 2016

    I tried this, but it doesn't work

    $('#LobbyTable tbody').on( 'click', 'tr', function () {
    var child = table.row( this ).child;
    
        child.show();
    
    } );
    
  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Thanks for the additional information.

    Its a bit of a workaround, but you could put the show / hide button into its own column and then hide that column (columns.visible), so the end user can't activate it.

    Otherwise you'd need to modify the Responsive library to do what you need.

    Allan

  • alamgiraalamgira Posts: 4Questions: 1Answers: 0

    Thank you so much, finally it is working.

This discussion has been closed.