0

I had a suggestion from another engineer to directly assign rowData since the rowData property name and selectedRule property name are the same, but I am having some issues with it and I am not sure if I am missing something. If you have any suggestions for DRYing this, let me know. Thanks!

/**
 * The selected rule data for a given row
 *
 * @type {Object}
 */
selectedRule = {
    name: '',
    level: '',
    action: '',
    target: '',
    startDate: '',
    endDate: ''
};

/**
 * Handles actions on each row in the datatable
 * @param {Object} event
 */
handleRowAction(event) {
    const action = event.detail.action;
    const rowData = event.detail.row;
    this.selectedRule = {
        action: rowData.action,
        level: rowData.level,
        name: rowData.name,
        target: rowData.target,
        startDate: rowData.startDate,
        endDate: rowData.endDate
    };
    switch (action.name) {
        case VIEW:
            this.dialog.showModal();
            break;
        default:
            break;
    }
}

}

1 Answer 1

0

Depending on what the intent is, you probably want to copy the object:

this.selectedRule = {...rowData};

If the data is immutable, you can:

this.selectedRule = rowData;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .