How to access row data in filterFunction of ng2-smart-table column?

Discussão em 'Angular' iniciado por Himanshu Kumar, Abril 11, 2025.

  1. stage: {
    title: 'Status',
    type: 'custom',
    valuePrepareFunction: (value, row) => {
    let statusText, customText, imgUrl;
    let showImg = false;
    if (value === 'PUBLISH') {
    customText = 'PUBLISH';
    } else {
    customText = 'PREVIEW';
    }
    if (row?.previewModule !== null) {
    showImg = true;
    imgUrl = './assets/clock.svg';
    }

    return JSON.stringify({
    severity: statusText,
    customText: customText,
    showImg: showImg,
    imgUrl: imgUrl,
    });
    },
    renderComponent: SmartTableWithBadge,
    filter: {
    type: 'list',
    config: {
    selectText: 'All',
    list: [
    { value: 'PREVIEW', title: 'PREVIEW' },
    { value: 'PUBLISH', title: 'PUBLISH' },
    ],
    },
    },
    filterFunction: (value, search) => {
    return value === search;
    },
    },


    My Goal: I want to modify the filter logic such that: Rows with previewModule!== null should show in the "PREVIEW" filter, even if their original value is PUBLISH.

    But in the filterFunction, I only have access to value and search, not the full row, which contains the previewModuleId field I need.

    Question: Is there any way to get access to the full row data inside the filterFunction of ng2-smart-table? Or is there a workaround to achieve this filtering based on both value and row.previewModule?

    Continue reading...

Compartilhe esta Página