problem merging views row-data into Drupal.settings I have a custom view and a custom row template.
For each row, the template defines a variable $rowdata.  For example:

&gt; row #0:  $rowdata = array(0=&gt;array('a','b'), 1=&gt;array('a','c'))  
&gt; row #1:  $rowdata = array(0=&gt;array('a','b'), 1=&gt;array('a','d'))
&gt; row #2:  $rowdata = array(0=&gt;array('x'), 1=&gt;array('x'))


What I Am Trying To Accomplish

I want merge the rowdata from all the rows:

   $merged_rowdata = array(
      0=&gt;array('a','b'), 
      1=&gt;array('a','c'), 
      2=&gt;array('a','b'), 
      3=&gt;array('a','d'), 
      4=&gt;array('x'), 
      5=&gt;array('x')
    )


and store the result in Drupal.settings.mymodule.$viewID.merged_rowdata:

Drupal.settings.mymodule.$viewID.merged_rowdata = array(
  0=&gt;array('a','b'), 
  1=&gt;array('a','c'), 
  2=&gt;array('a','b'), 
  3=&gt;array('a','d'), 
  4=&gt;array('x'), 
  5=&gt;array('x')
)


(Note:  All rows have the same value for $viewID)

What I Tried

I tried placing the following code in my row template:

drupal_add_js(array('mymodule' =&gt; array($viewID =&gt; array('merged_rowdata' =&gt; $rowdata))), 'setting');


But this does not merge the rowdata in the way that I want, as described above.  Instead, it replaces $viewID with the row_index:

Drupal.settings.mymodule = array(
  0 =&gt; array('merged_rowdata'=&gt;array(0=&gt;array('a','b'), 1=&gt;array('a','c'))),
  1 =&gt; array('merged_rowdata'=&gt;array(0=&gt;array('a','b'), 1=&gt;array('a','d'))),
  2 =&gt; array('merged_rowdata'=&gt;array(0=&gt;array('x'), 1=&gt;array('x')))
)


I found that if I replace the variable $viewID with a string literal, eg 'myview':

drupal_add_js(array('mymodule' =&gt; array('myview' =&gt; array('merged_rowdata' =&gt; $rowdata))), 'setting');


then the rowdata gets merged in the way that I want:

Drupal.settings.mymodule.myview.merged_rowdata = array(
  0=&gt;array('a','b'), 
  1=&gt;array('a','c'), 
  2=&gt;array('a','b'), 
  3=&gt;array('a','d'), 
  4=&gt;array('x'), 
  5=&gt;array('x')
)


Anyone know how I can get my desired result?  Is there some way to "tell" drupal_add_js that the variable $viewID has the same value for all the rows?

Background

My style template loops through each row of the view output, and executes the row template on each row.  Here is the code for my style template:

&lt;?php foreach ($rows as $id =&gt; $row): ?&gt;
  &lt;div&gt;
    &lt;?php print $row; ?&gt;
  &lt;/div&gt;
&lt;?php endforeach; ?&gt;
If the string literal is giving you what you want, I'd try this:

drupal_add_js(array('o4mmgal' =&gt; array($view-&gt;name =&gt; array('merged_rowdata' =&gt; $rowdata))), 'setting');