how can we achive pagination in layout grid without using foreach?.
Discussion posts and replies are publicly visible
My general recommendation: don't.
Further: if you want good advice here, tell us more about your use case and allow us to help you figure out solutions to your requirement, instead of figuring out how to reinvent the wheel or "build a better horse".
The problem is, paging among a data set where you're making active / unsaved changes opens up exponential avenues for accidentally losing / overwriting unsaved changes. My rule of thumb is if you need to ask about it here, you're not experienced enough to handle the implementation. Even I avoid this particular implementation because of how big of a chore it is to build, handle corner cases, then maintain in the future. In other words, there are at least a dozen better ways that use non-bespoke functionality.