Our blazing fast Grid component built with pure JavaScript


Post by audrius145 »

In the grid there is a column, that sets a type for an item. The problem is that when the grids search functionality is used it doesn't work against that columns displayed text, it actually works on the columns ids. Which makes sense because the column itself is a template column and it contains the ids of the types and through the template parameter it sets the displayed value as the text value from the combo.

Is there a way to make the search functionality to search on the displayed values instead?

Screenshot 2022-06-02 112033.png
Screenshot 2022-06-02 112033.png (12.5 KiB) Viewed 487 times

Post by marcio »

Hello,

You can check here https://bryntum.com/docs/grid/api/Grid/feature/FilterBar#enabling-filtering-for-a-column that we have a filterFn property that could help you.

filterable: {
	filterFn: ({ record, value }) => {
        	// Getting the text that is displayed and should be considered for filtering 
           	const valueToCompare = unitComboMap.get(record.value)
           	// Here I'm considering that's a string comparison, but you can return any 
           	// comparison function, as long as it returns a boolean value
         	return (
            		valueToCompare.toLowerCase().indexOf(value.toLowerCase()) !== -1
          	);
        },
        filterField: {
          	type: 'combo',
          	items: itemTypeArr,
        },
},
template: (record) => unitComboMap.get(record.value)

Best regards,
Márcio


Post by audrius145 »

Thanks for the reply!

Would it also be possible to do something like this for the grids search function? Looks like you cannot add your own function to searching.


Post by alex.l »

Not supported for now, unfortunately. It looks up on data level and not on UI level.
I've opened a feature request to make it configurable https://github.com/bryntum/support/issues/4745

All the best,
Alex


Post Reply