Pasteur Miranda
Posts: 0
Joined: Thu Aug 01, 2013 2:59 am

How to remove Lines in an Ionic Grid

Hi,

Code: Select all

In the Ionic/AngularJs PizzaCreator example, you show how to insert a line in a grid when  choose an ingredient and click the "add" button. Suppose, now, the user wants to remove an ingredient from the grid. I tried this, inserting a "delete" button in the row, and a method deleteItem() attached to the burron's ng-click directive. To remove the ingredient, I know that first I have to remove it from the $scope.customList array using the "delete" operator:  delete $scope.customList[INDEX]. My question is: 

1)How to get the INDEX of the item to be deleted in the Grid? 
2) How to remove the deleted ingredient's line from the Grid? 

         Thank You.
Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to remove Lines in an Ionic Grid

Hello,

You can get index of the current grid, if tou use track by $index: https://docs.angularjs.org/api/ng/dir...

Pasteur Miranda
Posts: 0
Joined: Thu Aug 01, 2013 2:59 am

How to remove Lines in an Ionic Grid

Hi, Sergiy.

I got the index of the current grid row $ index: I created a scope function named deleteItem(row), that was called from the ng-click directive of the delete button, using the $index: ng-click=deleteItem($index). The deleteItem(row) function code is
delete $scope.customList[row]. It works, It removes the ingredient from the customList, but the grid row is not deleted, it remains there, blanked. I would like to know how to delete this blank grid row.

Code: Select all

 Thank You
Pasteur Miranda
Posts: 0
Joined: Thu Aug 01, 2013 2:59 am

How to remove Lines in an Ionic Grid

Hi,
I solved just replacing $scope.customList[row] by $scope.customList.splice(row,1). Now, both array element and grid row are deleted.

Code: Select all

Thank you

Return to “Issues”