3

In the <lightning-datatable> documentation, there's an attribute suppress-bottom-bar which "If present, the footer that displays the Save and Cancel buttons is hidden during inline editing."

If you can't save inline edits, what's the point of having them?

I feel like there's something I'm missing here in my understanding of inline editing, saving, etc.

2 Answers 2

1

If you can't save inline edits, what's the point of having them?

Who said you can't save inline edits with the bottom bar suppressed?

There's two use cases I can think of:

  1. Perform some sort of auto-save mechanism as I answered in your Programmatically / Automatically Save Inline Edits on Datatable question
  2. Give the end user the flexibility to create their own button to handle the save themselves if they have specific UI considerations in mind.

Since the changes are stored in draftValues - users can handle that information as they wish outside the bottom bar "save" mechanism when leveraging suppress-bottom-bar

handleButtonClick(event){
    let draftValues = this.template.querySelector('lightning-datatable').draftValues;
    //pass to server-side apex method to do actual updating.
}

Since you're going around the standard save mechanism and implementing your own, you'll also have to explicitly clear out the draftValues attribute yourself so the table displays as if the standard save button was processed and you only get the changes that haven't been saved when the user inline edits the next time (or clicks the button).

1
  • This is perfect - now that I know I can access the draftValues outside of the onsave handler, this makes sense.
    – jbyrd
    Aug 24, 2021 at 18:31
0

In addition to the aforementioned usages, if you are nesting an LWC datatable within a Screen Flow you'll want to suppress the datatable's Save button in this way. Otherwise, you'll end up with two Save buttons, one of which only pops up during inline editing. I'm assuming that you could also run into this same issue if you are wanting to nest the datatable in another component and want the buttons to be either their own separate component or part of the parent.

You must log in to answer this question.

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