Our blazing fast Grid component built with pure JavaScript


Post by henrique »

I'm filtering a store connected to a grid, but when I apply the filter gives error: "TypeError: Cannot read properties of undefined (reading 'length')".

I've attached an image of the source location that's giving error.

I'm trying to reproduce the error in the examples, but I'm not succeeding.

Attachments
app.js
(13.4 KiB) Downloaded 46 times
Error image.
Error image.
Screenshot_1.png (39.04 KiB) Viewed 665 times

Post by mats »

What version are you using? Tried latest?


Post by henrique »

5.0.6


Post by henrique »

Making a debug here, it is applying a filter called "primary-filter". I can't identify where it's coming from.


Post by henrique »

I encountered the problem, when i activate the filter CallOnFunctions, but without any function configured, the error occurs!

import { Grid, DataGenerator } from '../../build/grid.module.js?459923';
import shared from '../_shared/shared.module.js?459923';

new Grid({

appendTo : 'container',

features : {
    filter: {callOnFunctions: true}
},

// Headers will ripple on tap in Material theme
ripple : {
    delegate : '.b-grid-header'
},

columns : [
    {
        text   : 'Name',
        field  : 'name',
        flex   : 2,
        editor : {
            type     : 'textfield',
            required : true
        }
    }, {
        text  : 'Age',
        field : 'age',
        width : 100,
        type  : 'number'
    }, {
        text  : 'City',
        field : 'city',
        flex  : 1
    }, {
        text  : 'Food',
        field : 'food',
        flex  : 1
    }, {
        text     : 'Color (not sortable)',
        field    : 'color',
        flex     : 1,
        sortable : false,
        renderer({ cellElement, value }) {
            // renderer that sets text color = text
            cellElement.style.color = value;
            return value;
        }
    }
],

data : DataGenerator.generateData(50)
});

Post by mats »

Ok, for the filter feature configured with an Object like that, you should provide a property to filter by:

 //<debug>
        if (!this._filterBy) {
            if (!this.property) {
                throw new Error('CollectionFilter must be configured with the name of a property to test in candidate items');
            }
        }
        //</debug>

Post by henrique »

I know that the filter configured this way must have the events. But it would be interesting to put this validation and give an error saying it was set wrong, then to show a property error that does not exist.


Post by alex.l »

Hi henrique,
Does it work well for you now?

All the best,
Alex


Post by henrique »

By removing the callOnFunctions, the error stop occurring. But I suggest putting the validation to give a clearer error to the programmer.


Post by mats »

Yes we'll ensure the error message is thrown not only in our own internal debug builds.


Post Reply