Lattices are used in such fields as electricity, optics and magnetism. Under investigation in this paper is an inhomogeneous discrete nonlinear Schrödinger equation, which models the wave propagation in a lattice. Employing the Kadomtsev–Petviashvili (KP) hierarchy reduction, we obtain the rogue-wave solutions, and see that the rogue waves are affected by the coefficient of the on-site external potential. We see (1) the first-order rogue wave with one peak and two hollows; (2) the second-order rogue waves, each of which is with one peak or three humps; (3) the third-order rogue waves, each of which is with one peak or six humps, and those humps exhibit the triangular pattern, anti-triangular pattern and circular pattern. When the coefficient of the on-site external potential is a constant, the rogue waves periodically appear. When the coefficient of the on-site external potential monotonously changes, oscillations emerge on the constant background.