[Data Grid Reactive] Data Grid Validation (Removed Rows)
Forge component by Bruno Martinho

Hello,


Not sure if there is already an opened topic about this.. When I remove a row that has been previously set "isValid" to false property with "SetValidationStatus" action, I cannot save changes to the grid because the variable

GetChangedLines.ChangedLines.HasInvalidLines

is true so it considers the Widget Grid with invalid parameters. Removed rows should not be included as InvalidLines since they were already removed, right?

1. So the user types an invalid Serial Number :

2. User removes the two invalid lines (without changing the Serial Number to a valid input).

3. User added a serial number "DTF" which is valid.

4. When User tries to save changes it sends back an error because the removed invalid lines are also considered changed lines, so the grid is invalid.

GetChangedLines.ChangedLines.HasInvalidLines (is true)

I thought of changing all the selected invalid lines to valid before it deletes as a work around, but still decided to come here and ask if I'm missing something. Let me know what you think!

Thanks!

PS

Solution

Not sure if it's the best practice but I came up with this solution. I turned the selected rows into valid before they were deleted, this way the grid will no longer have "hidden invalid rows" and

GetChangedLines.ChangedLines.HasInvalidLines (is false)

.


Extra: Maybe I am just too lazy but I guess if there was a custom optional config to avoid duplicate values into a column would be easier, or if you could provide/add an easy way to do it to the sample!

https://www.outsystems.com/ideas/10801/data-grid-reactive-allowduplicatevalues-columnoptionalconfigs/

mvp_badge
MVP

Hi Pedro,

Thank you for giving a thought on this and for sharing your use case! :)

Since you're actively looking into a solution, I would like to invite you to look into this component github repo, where all the logic and code of this component is, and propose your solution for the deleted lines through a PR! :)

To help you navigate the code there, please check the UML class diagram in the repo.

Hoping to see your solution done right! :)

Cheers,
RG

P.s. - since you are on it, it would be great if you could propose a solution also for the feature to avoid duplicates :)

I have no idea how I can propose the solution but I will have a look at it! My solution is working so I guess I can share and you can improve it.

Hey Ruben,

I attached my solution to avoid duplicate serial numbers and change status of the removed rows before deleting it (to avoid invalid hidden rows). I'm too bad at programming to propose something at github. I hope this helps the team as a start.

Thank you.

DataGridTesting.oml

mvp_badge
MVP


Hi Pedro,

Thank you so much for contributing to this component!
We'll make sure to analyze your proposal, and understand what is the best way to integrate this feature to our component.

We'll follow up with you regarding this topic.

Cheers,

Rúben

Hi Pedro,

I already had this problem and I was able to fix it clearing the InvalidRows using: 

GridAPI.GridManager.GetGridById(WidgetId).features.validationMark._invalidRows.length = 0

Probably it's not the best solution but it worked for me.

Best Regards,

Daniel Figueira

Thanks for the answer and help Daniel. I added a bit more context! Sorry!

mvp_badge
MVP

Hi Pedro,

Thank you for bringing this to discussion.

Can you give a little more context, business wise, of what are you aiming to do? (This will help the team have context and determine if this behavior is something that should be changed our if a sample should be provided instead).

Thank you for your understanding and help,

Cheers,

Rúben

I edited my question. You are right!

Sure,

So the user types an invalid Serial Number, everything is fine.

User removes the two invalid lines (without changing the Serial Number to a valid input).

User added a serial number "DTF" which is valid.

But when User tries to save changes it sends back an error because the removed invalid lines are also considered changed lines, so the grid is invalid.

GetChangedLines.ChangedLines.HasInvalidLines (is true)
Solution

Not sure if it's the best practice but I came up with this solution. I turned the selected rows into valid before they were deleted, this way the grid will no longer have "hidden invalid rows" and

GetChangedLines.ChangedLines.HasInvalidLines (is false)

.


Extra: Maybe I am just too lazy but I guess if there was a custom optional config to avoid duplicate values into a column would be easier, or if you could provide/add an easy way to do it to the sample!

https://www.outsystems.com/ideas/10801/data-grid-reactive-allowduplicatevalues-columnoptionalconfigs/

mvp_badge
MVP

Hi Pedro,

Thank you for giving a thought on this and for sharing your use case! :)

Since you're actively looking into a solution, I would like to invite you to look into this component github repo, where all the logic and code of this component is, and propose your solution for the deleted lines through a PR! :)

To help you navigate the code there, please check the UML class diagram in the repo.

Hoping to see your solution done right! :)

Cheers,
RG

P.s. - since you are on it, it would be great if you could propose a solution also for the feature to avoid duplicates :)

I have no idea how I can propose the solution but I will have a look at it! My solution is working so I guess I can share and you can improve it.

Hey Ruben,

I attached my solution to avoid duplicate serial numbers and change status of the removed rows before deleting it (to avoid invalid hidden rows). I'm too bad at programming to propose something at github. I hope this helps the team as a start.

Thank you.

DataGridTesting.oml

mvp_badge
MVP


Hi Pedro,

Thank you so much for contributing to this component!
We'll make sure to analyze your proposal, and understand what is the best way to integrate this feature to our component.

We'll follow up with you regarding this topic.

Cheers,

Rúben

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