Is it possible to change datatype of a cell from autocomplete to dropdown based on another cell input

Tags: #<Tag:0x00007efc620a6148>

Hi,

In our application, we need to change the cell datatype from autocomplete to dropdown select (initially it will be autocomplete) based on particular value entry on previous cell.

image

Scenario 1:

In the above image, When we add any value in DCC column, the Ingredient/Inputs/Product Name column should be changed to dropdown datatype.

Scenario 2:

Or if the above Scenario is not possible, Is it possible to restrict the user to type if autocomplete field has dropdown values. The user should be able to type only if there is no dropdown values. Is there any code workaround for customized autocomplete editor for this 2nd Scenario.

Code reference below:

if (col.field_name === ‘Ingredient/Input/ProductName’) {
colSpecification.type=‘autocomplete’;
colSpecification.source = [‘chips’ , ‘biscuits’ , ‘drinks’], // these source values will come from api based on value input in DCC column in above image - in this case, the user should be restricted to type anything in autocomplete cell since it has dropdown values.
}

We came across allowInvalid: true property, but our client needs the field should restrict to type itself, if there is dropdown values.

Thanks,
Karthikeyan V

Hi Karthikeyan,

did you already check the article about the cell dependencies on our blog at https://handsontable.com/blog/articles/2016/4/expand-your-app-with-cell-dependencies? If shares a couple of great examples on how to set cell dependencies.

In your case you can use the beforeChange() hook to run setCellMeta() method that changes the type of the cell and sets up the list of values to be chosen.

Hi,

I have tried beforeChange() hook for setCellMeta(), but still unable to achieve changing the datatype. But, anyway our team decided to use Strict method in autocomplete to throw error to the user. Thanks anyway!

Ok. I understand. Thank you for the update. I’m closing this thread.