Conventional wavelength-scanning phase retrieval introduces different illumination wavelengths for acquiring phase diversity intensity measurements. However, slow-varying phase information cannot be converted to intensity variations for detection. As a result, the low-frequency contents of the phase profile cannot be properly restored in the phase retrieval process. To address this challenge, in this Letter we present a spatially coded wavelength-scanning approach (scWS), a novel (to the best of our knowledge) method that synergizes wavelength scanning with spatial-domain coded detection for true quantitative phase imaging. In our scheme, we add a thin coded layer on top of the image sensor for encoding the slow-varying phase information into the intensity measurements with modulated patterns. Inspired by the coded ptychographic imaging, we report a reconstruction scheme to jointly recover the complex object and the unknown coded layer. With both simulation and experimental results, we show that the recovered phase is quantitative and the slow-varying phase profiles can be properly restored in post-acquisition reconstruction. Additionally, the reported approach can obtain a better image quality compared to the conventional wavelength-scanning approach. The development of a scWS lensless on-chip microscopy (LOM) platform is expected to inspire applications in the realm of computational microscopy, especially in applications where portable and in situ measurements are required.