Context. Because of high charge-to-mass ratio, the nanodust dynamics near the Sun is determined by interplay between the gravity and the electromagnetic forces. Depending on the point where it was created, a nanodust particle can either be trapped in a non-Keplerian orbit, or escape away from the Sun, reaching large velocity. The main source of nanodust is collisional fragmentation of larger dust grains, moving in approximately circular orbits inside the circumsolar dust cloud. Nanodust can also be released from cometary bodies, with highly elongated orbits. Aims. We use numerical simulations and theoretical models to study the dynamics of nanodust particles released from the parent bodies moving in elongated orbits around the Sun. We attempt to find out whether these particles can contribute to the trapped nanodust population. Methods. We use two methods: the motion of nanodust is described either by numerical solutions of full equations of motion, or by a two-dimensional (heliocentric distance vs. radial velocity) model based on the guiding-center approximation. Three models of the solar wind are employed, with different velocity profiles. Poynting-Robertson and the ion drag are included. Results. We find that the nanodust emitted from highly eccentric orbits with large aphelium distance, like those of sungrazing comets, is unlikely to be trapped. Some nanodust particles emitted from the inbound branch of such orbits can approach the Sun to within much shorter distances than the perihelium of the parent body. Unless destroyed by sublimation or other processes, these particles ultimately escape away from the Sun. Nanodust from highly eccentric orbits can be trapped if the orbits are contained within the boundary of the trapping region (for orbits close to ecliptic plane, within ∼0.16 AU from the Sun). Particles that avoid trapping escape to large distances, gaining velocities comparable to that of the solar wind.