GigaTables / reactables

GigaTables is a ReactJS plug-in to help web-developers process table-data in applications and CMS, CRM, ERP or similar systems.
MIT License
144 stars 30 forks source link

how to send default value in create-editor to the back-end just like in edit-editor? #122

Closed xuanxiaodeyu closed 6 years ago

xuanxiaodeyu commented 6 years ago

I can make create-field show default value via adding a attribute named 'value', but it can't be sent to the back-end until I edit it. I think it's because only when the create-field is edited, the function 'onChange( )' will be called and then the data can be written in the request. But I want every create-field has a default value, even if I don't edit some fields, all data including edited data and no-edited data can be sent to the back-end. I found the edit-editor is just like what I want. The fields in edit-editor all have a pre-filled value, and I just need to edit one field and all data in other fields can also be sent to the back-end. So can I set default value in create-editor just like in edit-editor?

arthurkushman commented 6 years ago

This natively happens, because an edit form fills with data from the particular row, but create form fills-up by user, they should be empty until user or preset config options fills them correctly. I'll analyse this and try to adopt all fields to be pre-filled with default values.

arthurkushman commented 6 years ago

Here is a patch - https://github.com/GigaTables/reactables/releases/tag/2.7.5 You can set default values on form elements.

xuanxiaodeyu commented 6 years ago

I tried this version and added a defaultValue to the field, the editor displays the defaultValue when opened, but it still didn't be sent to the back-end after clicking the create-button untill the field is edited. I think this version can only display the defaultValue but can't send the defaultValue to the back-end.

arthurkushman commented 6 years ago

Patch - https://github.com/GigaTables/reactables/releases/tag/2.7.6 Try now - it should work either with defaultValue of each field + changed field values.

xuanxiaodeyu commented 6 years ago

Yeah, it works! Thanks.