115
Views
6
Comments
Solved
Data Grid Reactive 2.5.1 - GetChangedLines throws error adding rows to Empty List

I'm new to react and data grid, but have been able to successfully create patterns based on the documentation for adding rows, removing rows, and editing rows.   The only issue I've run into is that I seem to have a problem when the data grid is initially empty and I want to add the first row.  When I click on the Save button that contains the GetChangedLines after entering my data in the empty row, GetChangedLines throws the error "Cannot convert undefined or null to object."  Is there some part of the pattern I'm missing when a data grid is initially empty?   Do I need to do something prior to calling GetChangedLines if the data grid is starting from an initially empty state?

2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Lennie,

Meanwhile, the OutSystems team is investigating the case. I do have a solution to suggest. Based on my observation, I understood that the underlying javascript implementation fails to handle the serialized JSON object of the Aggregate output list containing computed (Adhoc) attributes.

Implementation Steps:

  • Define a structure (LineItemSTR) comprising all the attributes required in the serialized JSON object 
  • Define a local variable (LineItemSTR_RL) of newly defined structure record list type
  • Assign the Aggregate output list to the local variable of record list type and pass the same variable value to the DataArrange node
  • Do the necessary binding changes in the grid.


See this demo implementation: DataGrid | Orders

Refer to the attached .oml file


I hope this helps you!


Kind regards,

Benjith Sam 

DataGridEmptyTest.oml
2020-08-05 09-00-16
Gabriel Lundgren

Hey Lennie,


Thank you for bringing this topic into discussion. I've tried reproducing the scenario you mentioned, but I didn't get an error. Could you please send a sample so I could try to understand what's going on your side?


Best regards,

Gabriel Lundgren

2017-12-15 03-31-24
Lennie Sutton

Hey, Gabriel.  

I created a simple Order/Line Item application and was able to duplicate the same scenario that I have in my larger application.   I think I must be doing something wrong, but I'm not sure what it is.

Best regards,

Lennie Sutton

DataGridEmptyTest.oml
2020-08-05 09-00-16
Gabriel Lundgren

Hey Lennie,


It seems we are the ones doing something wrong. We'll have a look at this issue and let you know how to proceed as soon as possible. 


Best regards,

Gabriel Lundgren

2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Lennie,

Meanwhile, the OutSystems team is investigating the case. I do have a solution to suggest. Based on my observation, I understood that the underlying javascript implementation fails to handle the serialized JSON object of the Aggregate output list containing computed (Adhoc) attributes.

Implementation Steps:

  • Define a structure (LineItemSTR) comprising all the attributes required in the serialized JSON object 
  • Define a local variable (LineItemSTR_RL) of newly defined structure record list type
  • Assign the Aggregate output list to the local variable of record list type and pass the same variable value to the DataArrange node
  • Do the necessary binding changes in the grid.


See this demo implementation: DataGrid | Orders

Refer to the attached .oml file


I hope this helps you!


Kind regards,

Benjith Sam 

DataGridEmptyTest.oml
2017-12-15 03-31-24
Lennie Sutton

Hi, Benjith,

   Thank you so much for the suggestion and example.  I've applied this pattern to my particular use-case and it worked perfectly!  I think I will just adopt this pattern whenever I use data grid.

Best regards,

Lennie

2021-03-18 21-03-15
Benjith Sam
 
MVP

You're welcome, Lennie.

Glad to help you :)


Kind regards,

Benjith Sam

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