Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

ListGrid.getField('length') returns the number of fields instead of 'length' fiel

$
0
0
ListGrid.getField returns a field definition based on a column number of field name. The problem is that if the field is name 'length' it does not return the field definition for the 'length' field, but the size of the fields array.

This is an excerp from the beginning of the getField function:
Code:

    if (this._noNumericFields) {
        field = this.fields[id];
        if (field != null) return field;
    } else {
        // Number: assume index.
        if (isc.isA.Number(id)) return this.fields[id];
    }

In our case this._noNumericFields is true. When this function is called with 'length' as the id parameter, this is executed:

field = this.fields['length'];

This is equivalent to this.fields.length, which is the length of the fields array. Being field not null, it is returned in the next line. This could be avoided if it is checked not only if field is not null, but also if field is an object:

Code:

    if (this._noNumericFields) {
        field = this.fields[id];
        if (field != null && isc.isAn.Object(field)) return field;
    } else {
        // Number: assume index.
        if (isc.isA.Number(id)) return this.fields[id];
    }

I am working with Smartclient v10.0d_2014-02-13/LGPL Deployment.

Thanks and regards,

Viewing all articles
Browse latest Browse all 4756

Trending Articles