Looping through grid rows after deleting rows and re-adding

Posted by IramK on 30-Jun-2015 03:32

Hello,

I have come across this situation that I am doing a duplicate check on a particular field based on the onUpdate event of  a grid control. If I keep adding rows i.e. records in a sequence one after the other, it works fine as the indexes start from 0 and go on till 'n' number of records. However if I would then delete a couple of rows from the list of rows(towards the end) and add three more rows, the indexes change and now in this situation I cannot loop through from 0 to 'n' records. The row indexes will be something like 0,1,2,3,6,7,8 etc. What is the best way to loop through all the rows of this grid control such that if I do what I did above, or delete all rows and re-add them again or delete rows from the top etc, the looping will work regardless? Any suggestions?

Cheers.

Posted by Gian Torralba on 06-Jul-2015 10:45

Hello,

You could use JQuery to count the number of current grid rows in the page. You can use $().each on each "tr" row. Just make sure that you are referencing the correct grid index (check the class name of the grid and the child tr element).

Hope this helps,

Gi

All Replies

Posted by Gian Torralba on 06-Jul-2015 10:45

Hello,

You could use JQuery to count the number of current grid rows in the page. You can use $().each on each "tr" row. Just make sure that you are referencing the correct grid index (check the class name of the grid and the child tr element).

Hope this helps,

Gi

Posted by IramK on 06-Jul-2015 10:47

Thanks, that is exactly what I have done.

This thread is closed