How to get only specific table columns?

How to achieve the above functionality. I tried different ways but none seem to work correctly.

What have you tried so far?

I would probably try a .filter method and return only the properties that you don't want eg
allColumns.filter(x => !["Account_ID","Product_ID","Bulk_Update"].includes(x));

If you're not worried about modifying the array you can use lodash _.pull method which does basically the same thing:
_.pull(allColumns, "Account_ID","Product_ID","Bulk_Update")

If that's a little clunky, or the list of column names is likely to change you could consider a regexp to match columns that start with a number instead:
allColumns.filter(x => x.match(/^[0-9]+/))

I did try allColumns.filter but this always returns as:

image

._pull returns the output but result remains unchanged:

Ah, didn't read that it was a legacy table property - it looks like your allColumns is an object not an array, so you should need to convert it first

try this:

return _.pull( {{ _.values(tableLegacy5.columns) }}, "Account_ID","Product_ID","Bulk_Update" );

2 Likes

Thanks it worked.