Delete not working on multiple pages

Posted by: sdayal on 23 August 2021, 12:33 am EST

    • Post Options:
    • Link

    Posted 23 August 2021, 12:33 am EST - Updated 3 October 2022, 12:37 pm EST

    Hi team,

    In the below snippet, If i Select rows from different pages then If I press delete button then It changes color of rows shown in the current pages but it doesn’t changes the color of all rows on different pages.

    On pressing Delete button it should change the color of all the selected rows in all the pages.

    https://stackblitz.com/edit/angular-yykuqr?file=src/app/app.component.ts

    Please provide solution for this.

    Thank you.

  • Posted 23 August 2021, 12:34 am EST

    Refer line :- 666

    
      deleteUser() {
        const view = this.grid.collectionView as wjcCore.CollectionView;
        for (let i = this.grid.rows.length - 1; i >= 0; i--) {
          let flag = false;
          if (this.grid.rows[i].isSelected) {
            // this.grid.rows[i].cssClass = this.cssClassDelete;
            this.grid.rows[i].dataItem._isColor = true; //optional
            // save className in dataItem itself
            this.grid.rows[i].dataItem._cssClass = this.cssClassDelete;
            flag = true;
    
            //un-checking the selector checkboxes
            this.grid.rows[i].isSelected = false;
          }
          if (flag && this.grid.rows[i].dataItem.id === 1000) {
            view.remove(this.grid.rows[i].dataItem);
          }
        }
        this.grid.invalidate();
      }
    
  • Posted 23 August 2021, 11:18 pm EST

    Hi Team,

    Please provide solution for this.

    Regards

  • Posted 24 August 2021, 3:31 am EST

    Hi,

    To set the deleted class to all the rows(in all pages), instead of iterating over the rows you may iterate on the sourceCollection array because the rows array only contain the current rows. Please refer to the sample below:

    https://stackblitz.com/edit/angular-4hm9ir

    Regards,

    Ashwin

  • Posted 25 August 2021, 11:38 pm EST - Updated 3 October 2022, 12:35 pm EST

    Hi Ashwin,

    Applying above changes are not working for all pages. The row which we select last in any page, remains checked.

    Please look into this.

    Thank you.

  • Posted 25 August 2021, 11:40 pm EST

  • Posted 26 August 2021, 8:44 am EST

    Hi team,

    Please provide solution.

    Regards

  • Posted 26 August 2021, 11:22 pm EST

    Hi,

    We are working on this and will update you as soon as possible.

    ~regards

  • Posted 26 August 2021, 11:22 pm EST

    Hi,

    We are working on this and will update you as soon as possible.

    ~regards

  • Posted 27 August 2021, 1:00 am EST

    Hi,

    We apologize for the delayed response, the issue was caused because the delete operations were done only on the items having sel property set to true, and here sel is set on pageChanging event so to resolve the issue you need to add another condition inside the if statement to also check if the row is selected or not.

    You may refer to the updated sample link demonstrating the same:

    https://stackblitz.com/edit/angular-eeityr

    ~regards

  • Posted 27 August 2021, 2:12 am EST - Updated 3 October 2022, 12:37 pm EST

    Hi Ashwin,

    Understood the above solution logic and it’s working fine but in our snippet if we selected the filtered data using select-all header and delete it, then it is changing color of all the rows ( in all pages if we clear the filter ).

    Code: - https://stackblitz.com/edit/angular-eeityr

    Attached a gif for your reference

    Please look into this.

    Thank you.

  • Posted 27 August 2021, 7:15 am EST

    Hi Ashwin,

    Please help us with the solution.

    Regards,

  • Posted 29 August 2021, 11:36 pm EST

    Hi Ashwin,

    Please help us with the solution.

    Regards,

  • Posted 30 August 2021, 5:40 am EST

    Hi Ashwin,

    We need solution for this on urgent basis.

    please look into this issue.

    Regards,

  • Posted 30 August 2021, 11:25 pm EST

    Hi Shiv,

    We are working on this and will update you today only.

    ~regards

  • Posted 31 August 2021, 5:11 am EST

    Hi Ashwin,

    Is there any update ?

    Regards

  • Posted 31 August 2021, 6:09 am EST

    Hi,

    I have updated the deleteUser method to work on the filtered items. Previously, when you were checking all the items from the check all check box then all the items were set to checked by setting their sel property to true. Please refer to the updated sample link below:

    https://stackblitz.com/edit/angular-rcjp31

    The above sample will filter work on filtered items as well as non-filtered ones. Let us know if that’s works for you.

    Regards

  • Posted 31 August 2021, 7:27 am EST - Updated 3 October 2022, 12:37 pm EST

    Hi Ashwin,

    The color is getting applied to rows which are not selected as well.

    I’ve attached the gif to demonstrate the issue.

    I’ve selected [b]2 rows from page one , 2 from page 2nd and etc. [/b. and if I press delete and go back I can see on 1st page more than 2 rows are getting affected. and similar behavior when we delete using select-all header.

    Please provide solution for this.

    Regards

    Shiva

  • Posted 31 August 2021, 7:28 am EST

  • Posted 1 September 2021, 2:00 am EST

    Hello,

    For delete users, I have updated the method accordingly. Please refer to the code snippet below:

      deleteUser() {
        const view = this.grid.collectionView as wjcCore.CollectionView;
        let data = this.grid.collectionView.sourceCollection.filter((item) => {
          if(this.grid.collectionView.filter){
              return this.grid.collectionView.filter(item)
          }
          return true;
          })
        for (let i = view.sourceCollection.length - 1; i >= 0; i--) {
          let flag = false;
          if(data.length !== view.sourceCollection.length){
            for (let j = 0; j < data.length; j++) {
              if(JSON.stringify(data[j]) == JSON.stringify(this.grid.collectionView.sourceCollection[i])){
                this.deleteUserSub(view,this.grid,flag,i)
              }
            }        
          }else{
            this.deleteUserSub(view,this.grid,flag,i)
          }       
          //un-checking the selector checkboxes
          view.sourceCollection[i].sel = false;
          if(this.grid?.rows[i]){
            this.grid.rows[i].isSelected = false;
          }    
        }
        this.grid.invalidate();
      }
    
      deleteUserSub(view,grid,flag,i){
        if (view.sourceCollection[i].sel) {
          // save className in dataItem itself
          view.sourceCollection[i]._cssClass = this.cssClassDelete;
          flag = true;
        }
        if (flag && view.sourceCollection[i].id === 1000) {
          view.remove(view.sourceCollection[i]);
        }
      }
    

    You can also use this code snippet for your different page size samples. You may also refer to the sample link below demonstrating the same:

    https://stackblitz.com/edit/angular-faoxhk?file=src/app/app.component.ts

    Regards

  • Posted 2 September 2021, 2:00 am EST

    Hi Sonu,

    This Works.

    Thank you !

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels