DataMap and empty item

Posted by: andrew.k.yohn on 18 August 2020, 10:56 am EST

    • Post Options:
    • Link

    Posted 18 August 2020, 10:56 am EST

    I have a DataMap on a FlexGrid column. I need to be able to clear the option, so I put an empty value option into the DataMap. Once an item is selected, if the user selects the first/empty option (in my example below displays a ‘.’), the grid will not accept the empty cell value, it keeps the previous value.

    let statusMap = new wijmo.grid.DataMap([{val: ‘’, display: ‘.’}, {val: ‘C’, display: ‘Complete’}, {val: ‘P’, display: ‘Pending’}], ‘val’, ‘display’);

  • Posted 18 August 2020, 12:19 pm EST

    I believe I found a work-around. I had to reset the dataItem of the row to an empty string on cellEditEnding.

    (In my code, the column was index 4 and the column was mapped to the ‘status’ element of the dataItem).

            cellEditEnding: function (s, e) {
                if (e.col == 4) {
                    let newVal = s.activeEditor.value;
                    if (newVal == '.')
                        s.rows[e.row].dataItem.status = '';
                    e.cancel = false;
                }
            },
    
  • Posted 19 August 2020, 12:18 am EST

    Hi Andrew,

    Instead of setting the status in cellEditEnding event, you could use the isRequired property of the Column. The columns with DataMap are required by default, so if you will set this property to false, then you can enter empty values:

    grid.columns[4].isRequired = false;
    

    API: https://www.grapecity.com/wijmo/api/classes/wijmo_grid.column.html#isrequired

    Regards,

    Ashwin

  • Posted 19 August 2020, 9:16 am EST

    That worked, thanks!

Need extra support?

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

Learn More

Forum Channels