Selection save into not working in grid field

Hi, I am using a grid field and a rule input to save the selected rows, but all the selected row values are not saved in the rule input. Suppose I am selecting four rows only the value of 2 rows is saved in the rule input. When I select all the rows at once this is a problem. But if I select one row after other it doesn't create a problem.Attaching the code snippet for reference:

Any help in this regard will be appreciated.

  Discussion posts and replies are publicly visible