does this imply that only certain wavelength can diffraction from the slits?
That is to say, wavelength represents certain wave, or in other words, certain frequency, so that it select the frequency from the light wavepackets after the slits.
If so, samely for grating, then.
Maybe this is the way it works in dispertion of lights.
Literally, the ability of a diffraction grating to separate light of different wavelength is not based on dispersion. At least in the usual understanding, dispersion is a frequency dependency of phase velocity. A prism monochromator e.g. utilizes dispersion.