Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Programmatically adding rows to grid

21 views
Skip to first unread message

Erik

unread,
Jul 3, 2009, 2:14:05 PM7/3/09
to
Is it possible to programmatically add rows to a grid? I tried giving
the <rows> element an ID but getElementById() returns null. I guess the
grid is like the tree in that the content doesn't exist in the DOM. How
can I access the rows/columns from javascript? Google didn't help.


Thanks,
Erik

Dave Townsend

unread,
Jul 3, 2009, 2:15:34 PM7/3/09
to

What you tried should work just fine, assuming you waited for the DOM to
load before calling getElementById as normal. Could you supply code that
failed?

Erik

unread,
Jul 3, 2009, 7:31:28 PM7/3/09
to
I forgot to mention that if I put the ID on the <grid> element instead
then it works, although for obvious reasons the rows added are not
aligned properly because they are not children of the <rows> element as
they should be.

So the XUL must have loaded because I can access the <grid> by ID but I
cannot access the <rows> by ID. Any thoughts?

My code is below, which causes "strings is null" in the error console
when the final statement tries to append the new row to the <rows> element.


Thanks,
Erik


<grid>
<columns><column/><column flex="1"/><column flex="1"/></columns>
<rows id="locale_strings_rows"/>
</grid>


strings=document.getElementById('locale_strings_rows');

row=document.createElement('row');
row.setAttribute('align','center');
row.setAttribute('contextmenu','locale_strings_menu');
row.addEventListener('mouseover',locale_strings_list_mouse,false);
row.addEventListener('click',locale_strings_list_mouse,false);
row.addEventListener('mouseout',locale_strings_list_mouseout,false);

temp=document.createElement('label');
temp.setAttribute('class','locale_strings_list_string_id');
temp.setAttribute('flex','1');
temp.setAttribute('value',string_id);
row.appendChild(temp);

temp=document.createElement('textbox');
temp.setAttribute('flex','1');
temp.setAttribute('multiline','true');
temp.setAttribute('readonly','true');
temp.setAttribute('value',value);
row.appendChild(temp);

temp=document.createElement('textbox');
temp.setAttribute('flex','1');
temp.setAttribute('multiline','true');
temp.setAttribute('readonly','true');
temp.setAttribute('value',translated_value);
row.appendChild(temp);

strings.appendChild(row);

Dave Townsend

unread,
Jul 4, 2009, 4:25:11 AM7/4/09
to
On 04/07/2009 00:31, Erik wrote:
> I forgot to mention that if I put the ID on the<grid> element instead
> then it works, although for obvious reasons the rows added are not
> aligned properly because they are not children of the<rows> element as
> they should be.
>
> So the XUL must have loaded because I can access the<grid> by ID but I
> cannot access the<rows> by ID. Any thoughts?
>
> My code is below, which causes "strings is null" in the error console
> when the final statement tries to append the new row to the<rows> element.

I don't know what could be going wrong, I just copied that code into a
quick XUL test and it seemed to work ok.

0 new messages