Suppose we got a Lamp L that emits some light. The light afterwards hits a diffraction Grating G at a distance a. Now if you were to look through the grating with your Eye E, you were to see the interference Maxima M that are a distance x away from the origin of the Lamp (for the arrangement look below).
The formula for calculating the wavelength $\lambda$ of the light is said to be
$$ \mathrm{\lambda = g\cdot\dfrac{x}{\sqrt{a^2 + x^2}}}$$
where only the lattice constant $\textsf{g}$, the distance $\textsf{a}$ and the spacing $\textsf{x}$ have to be known (assuming first order).
$\underline{\text{What is totally unclear to me is why this is the case.}\:}$ Of course I know the simple derivation of the formula above, but that assumes that the $\textsf{grid}$ and the $\textsf{screen}$ are at a distance $\textsf{a}$ apart.
I don't understand why the distance between $\textsf{object}$ and $\textsf{grid}$ matters because the diffraction only happens after the light passes the grating. According to my understanding the distance between light and grating doesn't matter if you consider the interference pattern at a screen.
(But of course here we don't have screen but our prying eye)