3

My Plunker.

In My plunker if I add some childs, then if I remove one of child record then if I add rows the rows are duplicating.

$scope.newSubItem = function(scope) {
  var nodeData = scope.$modelValue;
  nodeData.items.push({
    id: nodeData.id * 10 + nodeData.items.length,
    rowId: nodeData.rowId + '.' + (nodeData.items.length + 1),
    items: []
  });
};

1 Answer 1

2

Instead of adding nodeData.items.lenght add this for id

id: nodeData.items.length?(nodeData.items[nodeData.items.length-1].id)+1:nodeData.id * 10

And for rowId add this

 rowId: nodeData.rowId + '.' + ((nodeData.items.length?(parseInt(nodeData.items[nodeData.items.length-1].rowId.split('.').pop()))+1:0)),
Sign up to request clarification or add additional context in comments.

1 Comment

you need to make this change in addParentRow function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.