In this study we elaborate on the recent concept of metagratings proposed in Ra'di et al. [Phys. Rev. Lett. 119, 067404 (2017)] for efficient manipulation of reflected waves. Basically, a metagrating is a set of 1D arrays of polarization line currents which are engineered to cancel scattering in undesirable diffraction orders. We consider a general case of metagratings composed of N polarization electric line currents per supercell. This generalization is a necessary step to totally control diffraction patterns. We show that a metagrating having N equal to the number of plane waves scattered in the far-field can be used for controlling the diffraction pattern. To validate the developed theoretical approach, anomalous and multichannel reflections are demonstrated with 3D full-wave simulations in the microwave regime at 10 GHz. The results can be interesting for the metamaterials community as allow one to significantly decrease the number of used elements and simplify the design of wavefront manipulation devices, what is very convenient for optical and infra-red frequency ranges. Our findings also may serve as a way for development of efficient tunable antennas in the microwave domain.