Access column data from within dataMap.getDisplayValues

Posted by: rusty on 14 June 2021, 5:45 am EST

    • Post Options:
    • Link

    Posted 14 June 2021, 5:45 am EST

    Hi, I am using the dataMap.getDisplayValues method as I need to create a Dynamic Datamap that returns a subset of the values based on the row data.

    Is there a way to access the column data from within the getDisplayValues method?

    I only need access to the dataMap property of the column.

  • Posted 15 June 2021, 4:02 am EST

    Hi Rusty,

    Since getDisplayValues is a regular function in javascript you may access the column properties as close inside the getDisplayValues like:

    var theGrid = new wijmo.grid.FlexGrid('#app', {
        autoGenerateColumns: false,
        columns: [
          { binding: 'country', header: 'Country' },
          { binding: 'city', header: 'City' }
        ],
        itemsSource: getData()
      });
    
    // create map
    var cityMap = new DataMap(getCities(), 'id', 'name');
    // override getDisplay values
    cityMap.getDisplayValues = function(rowDataItem) {
        console.log(rowDataItem);
        // access column properties
        let col = theGrid.columns.getColumn("city");
        console.log(col.binding);
    
        let validCities = getCities().filter(
          city => city.country == rowDataItem.country
        );
        return validCities.map(city => city.name);
      };
    
    // assign data map
    theGrid.columns.getColumn("city").dataMap = cityMap;
    

    Regards

Need extra support?

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

Learn More

Forum Channels