getDataColumnName returns the displayName and not the name of a column

Posted by: gerald on 16 August 2020, 7:35 pm EST

    • Post Options:
    • Link

    Posted 16 August 2020, 7:35 pm EST

    I bound data to a sheet

    var colItemId = { name: "itemId", displayName: "Id", size: 70 };
        var colParentItemId = { name: "parentItemId", displayName: "Parent Id", size: 70 };
        var colItemName = { name: "itemName", displayName: "Name", size: 200 };
        var colRowIndentLevel = { name: "rowIndentLevel", displayName: "Level", size: 40 };
        var colRowIndex = { name: "rowIndex", displayName: "Row", size: 40 };
        this.sheet.autoGenerateColumns = true;
        this.dataSource = this.testDataService.loadItemsBasic();
        this.sheet.setDataSource(this.dataSource.items);
        this.sheet.bindColumn(4, colRowIndex);
        this.sheet.bindColumn(1, colRowIndentLevel);
        this.sheet.bindColumn(2, colItemId);
        this.sheet.bindColumn(3, colParentItemId);
        this.sheet.bindColumn(0, colItemName);
    
    

    When using getDataColumnName I receive the displayName and not the name of the field of the datasource.

    Example:

    When calling getDataColumnName:

    Expected: “rowIndex”

    Got: “Row”

  • Posted 17 August 2020, 9:46 pm EST

    Hi Gerald,

    We are able to replicate the issue at our end hence we have forwarded it to the concerned team for further investigation. We will update you regarding this as soon as we get updates, The internal Tracking ID for this issue will be SJS-5425.

    Regards

  • Posted 17 August 2020, 10:53 pm EST

    Thank you!

  • Posted 23 August 2020, 4:47 pm EST

    Hi Gerald,

    Devs have informed us that this is by design, further, they are interested in your use-case, could you please provide more information about your use case that why you need the actual name instead of the display name so that we could share it with the dev team.

    Regards

  • Posted 21 September 2020, 3:07 pm EST

    I wanted to use the column’s name in events to identify which field is currently focused. But I don’t need this actually, it was just experimental.

    You can close the issue.

    Thank you!

  • Posted 13 June 2023, 9:17 am EST - Updated 13 June 2023, 9:22 am EST

    I would like to re-open this case - and see if there is any way to get the data column name instead of the display name. The documentation mentions in the BindColumn method that if you specify the “column.name” it becomes “The name of the data source column.”. That way I can always safely locate the column I created, even if the user changes the display. This is essential when trying to keep the contents of the spreadsheet in sync with an underlying data source and on to the database itself.

    Thanks

    Ernie Blodgett

    IDF

  • Posted 13 June 2023, 6:28 pm EST

    Hi,

    For this, you may add your own function on the Worksheet class which returns the same. Please refer to the following code snippet and let me know if you face any issues.

    GC.Spread.Sheets.Worksheet.prototype.getColumnDataDisplayName = function(index){
        let columns = sheet.toJSON().columns;
        if(columns && index<columns.length){
            return columns[index].displayName;
        }
        return null;
    }

    Regards,

    Avinash

Need extra support?

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

Learn More

Forum Channels