Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    [BUG]: Setting hilitestate on ListGrid on create (example and solution included)

    Using the showCase http://www.smartclient.com/smartclie...ml#preferences

    [Observation/Example]:
    When you add hiliteState to the listGrid component in the example:
    Code:
    isc.ListGrid.create({
        ID: "countryGrid",
        width: "100%", height: 200,
        leaveScrollBarGap: true,
        canGroupBy: true,
        autoDraw: false,
        canFreezeFields: true,
        canAddFormulaFields: true,
        canAddSummaryFields: true,
        dataSource: ds,
        autoFetchData: true,
        hiliteState:[
          {"fieldName":"countryName","criteria":{
            "fieldName":"countryName","operator":"equals","value":"France","_constructor":"AdvancedCriteria"
          },"icon":"","cssText":"background-color:#FF6600;","backgroundColor":"#FF6600","id":0
          }
        ],
        fields: [
            {name: "countryCode", title: "Flag", type: "image", width: 50, imageURLPrefix: "flags/16/", imageURLSuffix: ".png", canSort: false},
            {name: "countryName", title: "Country"},
            {name: "capital", title: "Capital"},
            {name: "population", title: "Population"}, 
            {name: "area", title: "Area (km²)"} 
        ],
    draw : function() {
            this.Super("draw", arguments);
            viewStateTable.addData({pk: 0, name: "Default", viewState: this.getViewState()});
            preferenceSelectItem.setValue("Default");
        }    
    });
    The code will error: ErrorType: TypeError
    ErrorMessage: Cannot read property 'setProperty' of undefined.

    [Solution]:
    This is error is because data is undefined when settingup the hilitestate.
    Switching the two lines in the init of the ListGrid would solve this:
    Code:
     
     ISC_Grids.js@32467
        // Hilite state takes precedence over hilites because it is likely applied
        // from a user-saved location whereas hilites is the default.
        if (this.hiliteState) this.setHiliteState(this.hiliteState);
    
        // initialize the data object, setting it to an empty array if it hasn't been defined
        this.setData(this.data ? null : this.getDefaultData());
    to
    Code:
        // initialize the data object, setting it to an empty array if it hasn't been defined
        this.setData(this.data ? null : this.getDefaultData());
       
        // Hilite state takes precedence over hilites because it is likely applied
        // from a user-saved location whereas hilites is the default.
        if (this.hiliteState) this.setHiliteState(this.hiliteState);
    [Workarround]:
    Add data:[] to the create of the listgrid.
Working...
X