[Data Grid Reactive] Autofill cell value when typing in another column cell  (OnCellValueChange)
Forge component by Bruno Martinho
Application Type
Reactive

Hello,

I have a database table with 3 columns "Part Number" "Model" and "Type"

In this particular case, the user wants to be able to only type (reading the bar code) the "PartNumber" and it automatically detects the "Model" and "Type" associated in the database table.

I am trying to find a way to achieve this. I have tried to play with the dropdown column to only filter the model associated with the "PartNumber". The filter went well but I was not able to set a default value to cell, so I discarded this "not elegant" way to do it.

I have 0 knowledge of JS so I hope you can give me a hand here with a way to achieve this as I can't seem to know how to set a value to the "Model" column.


Thank you so much for your help.

Solution

Hello @PedroMSoares 

We are currently working on the feature to allow you to have a client action to set the value in a cell in the Grid, this should be out in the next Release.

Meanwhile, we have something to help, using one JavaScript line to achieve this:

GridAPI.GridManager.GetGridById($parameters.GridWidgetId).provider.setCellData($parameters.RowNumber, GridAPI.ColumnManager.GetColumnById($parameters.ColumWidgetId).indexPosition(), $parameters.NewValue, true);

In the attachment, you can find the sample, we have encapsulated the JavaScript so you will only need to use the client action.

We had to do some changes to the OML that you sent, so we could publish in our server, so be aware and don't publish it. Open it and copy to your own OML whatever you need.

This solution will change the value of the cell, but it won't deal with the dirty marks, this means that if you are editing a row, only the Part cell will have a dirty mark, the Model and Type won't. In our release, that already will be taken in account,

Please mind that we didn't test this solution in all use cases, the goal was to try to help unblock you.

Please let us know if this helped.

Thanks,

Bruno Martinho

DataGridTesting.oml

Hey Pedro,


Can you send us your sample so we can have a look at it?


Thank you,

Gabriel Lundgren

Hey,

Sure.

I have two entities created for this.

When changing "Part Number" it should fill "Model" and "Type" based on the manufactured entity. But yeah no idea how I can do it..

Thanks for your time!

DataGridTesting.oml

Solution

Hello @PedroMSoares 

We are currently working on the feature to allow you to have a client action to set the value in a cell in the Grid, this should be out in the next Release.

Meanwhile, we have something to help, using one JavaScript line to achieve this:

GridAPI.GridManager.GetGridById($parameters.GridWidgetId).provider.setCellData($parameters.RowNumber, GridAPI.ColumnManager.GetColumnById($parameters.ColumWidgetId).indexPosition(), $parameters.NewValue, true);

In the attachment, you can find the sample, we have encapsulated the JavaScript so you will only need to use the client action.

We had to do some changes to the OML that you sent, so we could publish in our server, so be aware and don't publish it. Open it and copy to your own OML whatever you need.

This solution will change the value of the cell, but it won't deal with the dirty marks, this means that if you are editing a row, only the Part cell will have a dirty mark, the Model and Type won't. In our release, that already will be taken in account,

Please mind that we didn't test this solution in all use cases, the goal was to try to help unblock you.

Please let us know if this helped.

Thanks,

Bruno Martinho

DataGridTesting.oml

Thank you so much for the help and such a fast answer, Bruno. I will adapt your method to my solution and wait for the feature. :)


Thanks to the team, also.

Best Regards,

PS

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.