Voltage-dependent anchoring of a nematic liquid crystal on a grating surface