material-table icon indicating copy to clipboard operation
material-table copied to clipboard

Major Issue in cellEditable while editing table cell, please check!!!!

Open priyankdeeps78 opened this issue 6 years ago • 10 comments

i am using material table in my code.I am using cell editable. But when i edit my table cell, its style become wierd. Please see the image. How to fix this.

Seems like its does not work well with too many rows.

can we change the styling...?? like remove cross button

and change check size?

Codesandbox code: https://codesandbox.io/s/material-demo-forked-h1f8d?file=/demo.js:1142-1513

Screen Shot 2020-12-04 at 12 00 24 PM

priyankdeeps78 avatar Dec 04 '20 08:12 priyankdeeps78

Easiest fix would be this: { title: "Surname",field: "surname",cellStyle: { minWidth: 150 },initialEditValue: "initial edit value"},

Samurus avatar Dec 09 '20 15:12 Samurus

@Samurus Is there anyway to remove those check and cross icon?? or change its size

priyankdeeps78 avatar Dec 09 '20 15:12 priyankdeeps78

please read documentation https://material-table.com/#/docs/features/component-overriding you can override EditField like this: components={{ EditField: (props) => ( <div style={{ backgroundColor: "#whatever" }}> maybe use input field here

) }} Alternatively please read documentation: https://material-table.com/#/docs/features/editable This examples shows how you can customize editable for one row. Accept and decline buttons are not needed in this case.

Samurus avatar Dec 11 '20 09:12 Samurus

@PriyankDeep @Samurus

Check ad Cross icons are implemented in EditCell component. This component is not listed in

https://material-table.com/#/docs/features/component-overriding

but it can be overrided like any others:

<MaterialTable<RowType>
          components={{
            EditCell(props) {
              return 'EDIT-CELL-OVERRIDE';
            }
          }
         {...otherProps}
</

You can use https://github.com/mbrn/material-table/blob/master/src/components/m-table-edit-cell.js as implementation example. This way you have full control over cell edition component

thefat32 avatar Dec 16 '20 18:12 thefat32

@Samurus @thefat32

I'm also trying to fix this issue and the EditCell component override only works if the cells you're editing are of the same type. If one of the cells uses a dropdown selection for example, like in my case, then that solution doesn't work, because it changes all cell edit types to a text field.

Also, setting cellStyle with to a minWidth of 150 or even 300 doesn't fix the issue that @PriyankDeep pointed out. I tried setting the individual columns width, as well as the cellStyle width and neither option fixed that specific issue.

kristinhorton avatar Jan 05 '21 19:01 kristinhorton

EditCell component receives columnDef with all details about the column including the type so you can render properly (EditField component is the one that renders depending on type (selector, chexkbox, text, etc) Do you have different cell types in the same column? Please if you can share with me your column's definition code.

thefat32 avatar Jan 05 '21 19:01 thefat32

@Samurus @thefat32 @kristinhorton @mbrn When using cellEdiatable, we have to first click on the cell, then edit it, click on check or cross button. But is there any way in which we can just click on tab button and make an edit. ??

I dont want that check and cross button on cellEdit.... I want it to be like, i click on cell and make an edit like normal input field (for numbers).

priyankdeeps78 avatar Jan 07 '21 06:01 priyankdeeps78

@PriyankDeep take a look at EditCell and EditField

Explaining short

  • EditCell receives onCellEditFinished callback
  • EditField has onChange property

You can reimplement EditCell to call onCellEditFinished when you want. I don't think you can make it work as a normal input as new value needs to be informed to material-table using the callback onCellEditFinished, this call ends edit process. But you can implement finish edition with Enter key and cancel edition with Esc key instead of check and cross icons.

thefat32 avatar Jan 07 '21 15:01 thefat32

@thefat32 can you show in codesandbox??

priyankdeeps78 avatar Jan 07 '21 15:01 priyankdeeps78

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

stale[bot] avatar Apr 07 '21 21:04 stale[bot]