Datatables Vue Responsive: Dynamic Search With Ajax Not Updating The Child Hidden Rows

Datatables Vue Responsive: Dynamic Search With Ajax Not Updating The Child Hidden Rows

paulhemen88paulhemen88 Posts: 21Questions: 3Answers: 0
edited February 3 in Free community support

I'm using Datatables Vue Component with Responsive Plugin. There's dynamic search on page which works when user enters any keyword on the screen.

But, it looks like the child row data is not getting updated e.g Here's the Table options I'm using:

    const dataTableOptions = {
        columnDefs: [
            { sortable: false, targets: [1, 2, stockColumn.value] },
            { width: '15%', targets: 1 }
        ],
        searching: false,
        stateSaveCallback: function (settings, data) {
            sessionStorage.setItem(btoa('customerPortalProducts'), JSON.stringify(data));
        },
        stateLoadCallback: function () {
            return JSON.parse(sessionStorage.getItem(btoa('customerPortalProducts')));
        },
        paging: true,
        stateSave: true,
        stateDuration: -1,
        processing: true,
        serverSide: true,
        responsive: {
            details: {
                renderer: DataTablesCore.Responsive.renderer.listHiddenNodes(),
                display: DataTablesCore.Responsive.display.childRowImmediate
            }
        },
        dom: '<"d-flex justify-content-between align-items-center py-2"lfr>t<"d-flex justify-content-between align-items-center py-2"ip>'
    };

Filter Code:

    debounceTimer.value = setTimeout(() => {
        if (dataTable.value) {
            let currentPage = dataTable.value.dt.page();
            dataTable.value.dt.ajax
                .url(
                    route('xxx.yyy.zzz', {
                        table: 'dataTable',
                        search_keyword: filterSearch.value ?? '',
                        search_category: filterCategory.value??'',
                        search_sub_category: filterSubCategory.value??''
                    })
                )
                // .load(null, refreshPage);
                .load(() => {
                    dataTable.value.dt.page(currentPage).draw("page");
    })
        }
    }, 700);

The issue is that hidden node data is not updated e.g I'm using <template> to show the Product image. But that Image remains the same.

I came across multiple solutions e.g https://live.datatables.net/muhadabi/1/edit but I don't see .register() in dataTable.value.dt API. I can see the _redrawChildren method in the Datatables Responsive class but unable to call it. So I feel stuck.

Answers

Sign In or Register to comment.