Forum Discussion

2 Replies

  • How about filtering by using Javascript:

    const table = [
        { id: 1, name: 'Alice', age: 25 },
        { id: 2, name: 'Bob', age: 30 },
        { id: 3, name: 'Charlie', age: 35 },
        { id: 4, name: 'David', age: 40 }
    ];
    

     

    An array list of IDs that you want to filter by:

    const arrayList = [1, 3];
    

     

    You can use the filter method to create a new array that includes only the rows from the table where the id is in the arrayList:

    const filteredTable = table.filter(row => arrayList.includes(row.id));
    
    console.log(filteredTable);
    

     

    The filteredTable will contain:

    [
        { id: 1, name: 'Alice', age: 25 },
        { id: 3, name: 'Charlie', age: 35 }
    ]
    

     

Resources