Make field/column in table required when editable

I have adding a new record to the table and bulk update all working with one exception. I would like to be able to set certain columns (fields) to be required. I do get an error back from the database when Not Null fields are not filled in, but it is gibberish to the users.

I suppose I could add Failure Conditions to the query to parse the error and translate it for the user.

Or I could fire a JS query to validate the record before triggering the insert/update queries.

Is there a cleaner way to do it?

2 Likes

I can’t think of a cleaner way to accomplish this at the moment, adding a “required” option to the column settings would be an awesome feature here.

Another hacky option to add ontop of this in the meantime would be some CSS to disable the save changes button based on evaluating some of the values in table.recordUpdates like this:

CSS here:

<style>
{{ table1.recordUpdates.map(row=>row.sales).filter(Boolean).length? ``: `#retool-widget-table1 > div > div.WidgetBoundingBox__widget > div._retool-table1 > div > div > div > div > div:nth-child(2) > div > div.-left > button.ant-btn.ant-btn-primary {
pointer-events: none;
background-color: grey;
color: lightgrey;
}`
}}
</style>

I’m going to go ahead and move this to the feature request section for the moment, this does seem like something that should be supported as a column setting.

2 Likes

+1 here. Also, it would be great if the users could see which field is mandatory before triggering the update. Like in some MySQL clients showing * beside the name of not null columns.

Noted, thank you!

Has this feature been added?

Hey @rgupta! Not yet, but I added your +1 to the internal feature request and will keep this thread updated with any changes :slight_smile: