how to keep the detail row in the DOM when it was collapsed ?

how to keep the detail row in the DOM when it was collapsed ?

jasieljasiel Posts: 6Questions: 2Answers: 0

Hi

I need to read several detail rows values but these have not been expanded, and when not expanded these are not generated in the DOM, so I need to read the values without having to expand all the detail rows

regards

Answers

  • kthorngrenkthorngren Posts: 21,329Questions: 26Answers: 4,949

    You are using Child Detail Rows and not the Responsive extension, correct?

    If so where does the data come from to generate the child rows? Likely you can access that same data to read the values you want. Please provide more solution details around how you are accessing the data to display the rows.

    Kevin

  • jasieljasiel Posts: 6Questions: 2Answers: 0

    $(document).on('click', 'td.details-control', function () {
    if (row.child.isShown()) {
    // This row is already open - close it
    row.child.hide();
    tr.removeClass('shown');
    } else {
    // Open this row
    var header = row.data();
    var detail = row.data().GET_SUB_DETAIL_CASE;
    row.child(format(row.data())).show();
    $.each(detail, function (index, value) {
    $('#id').append('<tr><td>value.name</td></tr>')

            }
            tr.addClass('shown');
    
    
        }
    

    });

  • kthorngrenkthorngren Posts: 21,329Questions: 26Answers: 4,949

    What is GET_SUB_DETAIL_CASE in row.data().GET_SUB_DETAIL_CASE?

    In the format function you are passing the row data row.child(format(row.data())).show();. I suspect the child row data is in the row data. So all you need to do is access the row data of the row you want to get the child detail data. You don't need to get ti from the DOM.

    Kevin

  • jasieljasiel Posts: 6Questions: 2Answers: 0

    GET_SUB_DETAIL_CASE is object that contain the values for detail table

  • kthorngrenkthorngren Posts: 21,329Questions: 26Answers: 4,949

    GET_SUB_DETAIL_CASE is in the row data so you can access it at any time whether the child row is open or not. They are independent of each other.

    Kevin

  • jasieljasiel Posts: 6Questions: 2Answers: 0

    the problem is when update someone value in grid , this no change in the object

  • kthorngrenkthorngren Posts: 21,329Questions: 26Answers: 4,949

    Please provide more details of how you are updating the values. If you aren't using Datatables API's to update the values then Datatables won't know about the changes to update its data cache.

    You can either use row().data() or cell().data() to have Datatables update the values. Or if you are updating the DOM directly you can use row().invalidate() or one of the other invalidate() APIs to have Datatables update its cache from your changes.

    If this doesn't help then please provide a test case replicating the issue. This way we can see what you are doing and can provide suggestions to fix.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

This discussion has been closed.