This example shows how to load a grid with data from a WFS capabilities document. Also shows how to have layer-specific object as properties of the 'layerOptions' property by using a function returning them.
Note that the js is not minified so it is readable. See wfscapabilities.js.