Anime =/= game.
Stuff that we're used to in the game isn't how it works in the anime. If the anime really did follow the game, Pikachu would've lost a lot more battles than he has, and Ash would never have made it past 8 gyms, let alone into the championships.
In the anime, I remember that Pikachu's T-bolt set off the sprinklers, and since Onix is doubly weak to water, Pikachu used another T-bolt to do some minute damage and Onix fainted. Onix actually took damage from T-bolt, but then again, Ash and Pikachu are known for their miracles.