jQuery DataTables: Expand only one row at a time and other row should be collapsed?

jQuery DataTables: Expand only one row at a time and other row should be collapsed?

Raj_BanotheRaj_Banothe Posts: 3Questions: 0Answers: 0
edited July 2022 in Free community support

I have a different solution. It Working fine with responsive table.

      var clicks = 0;
          $('#documents').on('click', 'tr td.dtr-control', function (e) {
            e.preventDefault();
            if(clicks == 3){
                clicks = 1;
            }
            clicks += 1;
            if(clicks <= 2){
                table.rows('.parent').nodes().to$().find('td:first-child').not(this).trigger('click');
                // OR use below code
                //$('#documents').find('.parent td.dtr-control').not(this).trigger('click');
            }
        });

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    Nice one - thanks for posting this.

    Allan

Sign In or Register to comment.