Our blazing fast Grid component built with pure JavaScript


Post by sipi41 »

Hello again, in my last question we had a problem when we tried to apply a custom combo to the filtering when using an integer, this was fixed by adding "filterType: 'string'," the problem we have now is that the custom function we want to apply our login is never executed (filterFn)

NOTE: Field "employeeId" is numeric, so the idea is to get this numeric field get filtered by a combo box with a custom function to return true/false and make the record appear.

{
                    text: 'Employee<br/>Type', field: 'employeeId', width: '6em', editor: false, htmlEncodeHeaderText: false,
                    renderer({ value }) {
                        if (value)
                            return employeeStore.getById(value).employeeType;
                        else
                            return '';
                    },

                filterType: 'string',
                filterable: {

                    filterField: {                            
                        type: 'combo',
                        multiSelect: true,
                        editable: false,
                        items: [...new Set(gridSourceData.employees.map(emp => emp.employeeType))].concat(BlankLabelFilter1),
                        pickerWidth: 200,
                    },
                    filterFn: ({ record, value, operator }) => {

                        console.log("executed!");

                        return true;

                        
                    }
                },
            },

For some reason, it never executes this function and basically, it just hides all records when selecting something from the combo as shown in the next picture.
Image

Thank you for all the help you may bring to this situation, thank you.


Post by Animal »

Do not "debug" using console.log.

Set a breakpoint where the field change event is fired and step it through. It should get in to FilterBar's onColumnFilterFieldChange

Start here. Step in when needed.

Screenshot 2022-03-25 at 17.49.32.png
Screenshot 2022-03-25 at 17.49.32.png (145.6 KiB) Viewed 884 times

Post by sipi41 »

Ok but the question is not answered, how can we resolve this situation? how can the filterFn executed when using a numeric value? in fact, I don't understand exactly what you are trying to explain...


Post by Animal »

It should be executed. The only way is to debug it. It's what I would do if I were in your situation.

Step the code.


Post by sipi41 »

Ok... to be sincere I don't know what exactly are we looking for and/or where to start, the code I sent you here is the code we have, when you say "Set a breakpoint where the field change event is fired and step it through. It should get in to FilterBar's onColumnFilterFieldChange" which part of my code is that? do you expect me to debug your code? sorry, maybe I don't understand... I saw the pic you posted and we don't even have a widget.js file...


Post by Animal »

The problem is likely in your code. I'm not saying there are no bugs in the system. But the only way to solve this is to get your hands dirty. Step code and see what happens.

You cannot just look from the outside and conjure up a solution.


Post by sipi41 »

Ok... I think we are going nowhere here, I would like to get help from somebody else, it was the same the last time you tried to help, it was more like my mom scoldings calling our js a "monolith" and I did not even reply because your help was not actually helping anybody, in fact, it is a monolith because that's the way it is shown on the docs, if the docs were teaching you to create a model, extend it, etc we probably would do it...

Please transfer this conversation to somebody else, maybe we will have this resolved as I'm wasting time here.


Post by sipi41 »

FOLLOW UP - After removing code, etc etc etc... we found the issue is related to the use of the same field in multiple columns, for example the Employee Column uses the EmployeeId, the Employee Type column also uses the the EmployeeId to identify the employee and display the value, in other words, in the column property we point to the same EmployeeId Field which causes the app to get confused and not run the function.

Is there a way to overpass this limitation?


Post by Animal »

Hi sipi41, sorry to strike the wrong tone. I thought I was helping.

The issue might be something to do with columns "claiming" ownership of filters. I will have to experiment with creating all kinds of filtering and column scenarios to see if this is the case and see if I can reproduce some buggy behaviour.


Post by alex.l »

Thanks for clarifications! Now we do see that bug, I've opened a ticket here: https://github.com/bryntum/support/issues/4408

Yes, as you described, the problem appears only if more than one field uses that field name. The cause in the way we make a mapping for filter functions in case of using that feature, to apply same filter data for all columns using that field. In case of using custom methods and fields for columns with same field name, it gives bugs. We have to investigate it deeply to have answers what can be done.

For now, try to avoid using same field name for that columns. Use custom renderer instead to show the value you need, if same data required to be shown in few columns. renderer has access to all record data.

All the best,
Alex


Post Reply