Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editing fields marked as non-editable when adding a new row #226

Open
lightheaded opened this issue Jan 21, 2016 · 9 comments
Open

Editing fields marked as non-editable when adding a new row #226

lightheaded opened this issue Jan 21, 2016 · 9 comments

Comments

@lightheaded
Copy link

When adding a new row, fields that are marked non-editable are automatically greyed out. I cannot find a way to configure the fields shown on adding a new record. It would seem like common sense that I might not want to let users edit certain fields, but when adding a new row, they should be able to enter the values in those immutable fields.

@AllenFang
Copy link
Owner

@lightheaded, could you show me the code? is all fields are non-editable?

@lightheaded
Copy link
Author

It's pretty much the example table code

<BootstrapTable data={products} striped={true} hover={true} pagination={true} selectRow={selectRowProp} cellEdit={cellEditProp}
                    insertRow={true} deleteRow={true} search={true} columnFilter={true} options={options}>
      <TableHeaderColumn dataField='id' isKey={true} hidden={true} editable={false}>id</TableHeaderColumn>
      <TableHeaderColumn dataField='phone_number' width='150px' editable={true}>Phone Number</TableHeaderColumn>
      <TableHeaderColumn dataField='reason' editable={true}>Reason</TableHeaderColumn>
      <TableHeaderColumn dataField='created_at' width='200px' editable={false}>Added</TableHeaderColumn>
    </BootstrapTable>

and the props:

var selectRowProp = {
  mode: 'checkbox',
  clickToSelect: true,
  className: 'info'
};

var cellEditProp = {
  mode: 'click',
  blurToSave: true,
  afterSaveCell: onAfterSaveCell
};

var options = {
  sizePerPage: 15,
  sizePerPageList: [15,50,500],
  sortName: 'created_at',
  sortOrder: 'desc',
  afterDeleteRow: onAfterDeleteRow,
  afterInsertRow: onAfterInsertRow
};

Now when I click "New", a popup appears that has two greyed-out fields - id and created_at. As ID is required, it is not possible to submit the form, although I don't want to submit the ID.

@AllenFang
Copy link
Owner

would you give the cellEditProp and the other props :)

@AllenFang
Copy link
Owner

oh. I see it. you set ``editable={false}on thecreated_at` and `id` both columns. so you can not insert new value.

@AllenFang
Copy link
Owner

btw, if you dont want id field be insert, you can set autoValue={true} on id field to tell react-bootstrap-table to generate a dummy rowkey

@lightheaded
Copy link
Author

I edited my post to include the props as well. Sorry about that :)

I do need the id field for updating the values, but the autoValue will come in handy when adding a new row (as id is currently my key column and the id is assigned by the backend, which causes delays). However with the editable=false, I would not like the created_at field to be edited, nor I want it to be filled out by user when adding a new row. I would like it to either be filled out automatically or be filled by backend without the react-bootstrap-table ever knowing about that field on insertion. Is that possible?

@AllenFang
Copy link
Owner

@lightheaded, did you mean you want to insert row without popup modal? sorry for my poor english:)
btw editable = false will make edit cell and insert can't be fill value both. maybe I can provide another configuration for you to make some column can't be edited but can fill value when insertion

@lightheaded
Copy link
Author

No I do like the popup, but I would like to configure the editability (update record) and insertion (new record) to be separately manageable. That would be great :)

@AllenFang
Copy link
Owner

ok, but there are a lots of issues and high priority features to do, so this will take some time, maybe can't be done in near future. If you urgent to need this feature, the workaround is just using cell edit only, and you customize a popup modal for insertion

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants