A knave of the first rate: a phrase borrowed from the dyehouse, where certain colours are said to be in grain, to denote their superiority, as being dyed with cochineal, called grain. Knave in grain is likewise a pun applied to a cornfactor or miller.
Definition taken from The 1811 Dictionary of the Vulgar Tongue, originally by Francis Grose.
See also the definition in Nathan Bailey's 1736 dictionary of canting and thieving slang.
Knappers Poll * Knight of the BladeNathan Bailey's 1736 Dictionary of canting and thieving slang
John S. Farmer's collection of canting songs and slang rhymes