I have a grid with pagination enabled and I need to navigate through the pages to find required row and click on it using protractor. I can click on a specific row in the 1st page but if it's not on the first page so I need to click next page and check for the required row.
element.all("by.id('value').filter((row) => {
  return row.getText().then((text) => {
    if (text.indexOf(text) != -1) {
      return true;
    }
  });
}).then((rows) => {
  if (rows)
    rows[0].element(by.name('name')).click();
});
Below code is running 5 times even if the element is found on 1st page
for(i=0;i<5;i++) {
  ( (i) =>{
    console.log('I:'+i);
    element.all("by.id('value').filter((row) => {
      return row.getText().then((text) => {
        if (text.indexOf(someval) != -1) {
          return true;
        }
      });
    }).then((rows) => {  
        if(matchingRows.length>0){
     matchingRows[0].element(by.css(this.button)).click();
        return;
      }
    });
  })(i);
next.click();
 }
}
 
    