Need to find the object type whether it is Row or Column (wijmo.grid.GridPanel)

Posted by: mmurugesan on 5 April 2019, 5:21 pm EST

    • Post Options:
    • Link

    Posted 5 April 2019, 5:21 pm EST

    Hi,

    I need to find the object type whether it is Row or Column. Here is my sample code (in TypeScript).

    public myMethod(panel: wijmo.grid.GridPanel, r: number, c: number, cell: HTMLElement): void {

    let className: any;

    if (panel.columns[c].binding === “Value”) {

    className = this.getClassName(panel.rows[r]);

    } else {

    className = this.getClassName(panel.columns[c]);

    }

    // code continues here



    }

    Here is the code in getClassName function:

    private getClassName(value: any): boolean {
        let columnName: any;
        let fieldDetails: FieldDetails;
        [b]if (value.GetType() === wijmo.grid.Row) {[/b]
            columnName = this.flexGrid.columns[1].header;
            fieldDetails = value._data.row.FieldDetails;
        [b]}else if (value.GetType() === wijmo.grid.Column) {[/b]
            columnName = value._hdr;
            fieldDetails = this.fields.find(field => field._aliasName === columnName);
        }
        // code continues here
        ...............
    

    }

    In my above getClassName, the value.GetType() in if and else if throws error as undefined.

    How to find the value type whether the passed object is Row / Column type ?

    Appreciate your ideas/suggestions.

    Thank you.

  • Posted 8 April 2019, 6:19 am EST

    HI,

    Inorder To check whether the object passed is an instance of a row or column, I suggest you should use instanceof operator instead of getType:

    private getClassName(value: any): boolean {
    let columnName: any;
    let fieldDetails: FieldDetails;
    if (value instanceof wijmo.grid.Row) {
    columnName = this.flexGrid.columns[1].header;
    fieldDetails = value._data.row.FieldDetails;
    }else if (value instanceof wijmo.grid.Column) {
    columnName = value._hdr;
    fieldDetails = this.fields.find(field => field._aliasName === columnName);
    }
    // code continues here
    ...............
    }
    
  • Posted 8 April 2019, 10:17 am EST

    Excellent. This works. Thank you very much…

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels