How to get the nodeid in node_grants so that it works in a view?
You actually need to implement two hooks:


hook_node_grants() which returns the grants a user has
hook_node_access_records() which returns the grants a node needs


It's the second hook that gets a node object, not the first. Keep in mind that you need to implement both the hooks.

As for hook_node_access(), this hook is called when a node is fully loaded, and it not called for node listings, as reported in the documentation.


  Also note that this function isn't called for node listings (e.g., RSS feeds, the default home page at path 'node', a recent content block, etc.) See Node access rights for a full explanation.


As for views, a view doesn't full load a node, but executes a SQL query to get node data. merlinofchaos clearly states it in Views does not respect hook_node_access.


  hook_node_access() is something that is run after a node is fully loaded. Since Views is loading nodes via query, you can't get the query to respect it unless you also use hook_db_rewrite_sql() which is what Views hooks into.
  
  This is not true of just Views, but any query that loads nodes. For example, the default Drupal front page will not respect hook_node_access() that isn't paired with hook_db_rewrite_sql() any better.
  
  hook_node_grants() and hook_node_access_records() will be used, however, if you set "Disable SQL rewriting" then you are specifically skipping that stuff.


Notice that hook_db_rewrite_sql() is not used from Drupal 7 and higher, though. The equivalent for Drupal 7 and higher is hook_query_alter().