How to insert item to a 2 columns listbox?!?!

View: New views
3 Messages — Rating Filter:   Alert me  

How to insert item to a 2 columns listbox?!?!

by davide sozzi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have created a listbox with 2 columns:

-Name
-Time

the listbox is inside a .xul file and through another .js file I add labels
to the listbox. Everything works but I can add items only to the first
column. I am trying to add items to both columns but I can't figure out how.

I don't want to type in the .xul file the

<listcell label="blabla"/>
<listcell label="blabla"/>

because the label changes quite often.


To make it easy le'ts assume that I want to type into a textbox what will
appear in the listbox... in this way I can't use the <listcell> comand.

I paste here part of the xul code:


<listbox id="bla1" rows="25" seltype="multiple" flex="0"  style="font-size:
10px; overflow-x: hidden;">
<listhead>
<listheader label="Name"/>
<listheader label="Time"/>
</listhead>

<listcols>
<listcol flex="1"/>
<listcol flex="1"/>
</listcols>

<listitem>
<listcell id="bla2"/>
<listcell id="bla3"/>
</listitem>
</listbox>



and to insert he item in the listbox I use:


function si(event)
{
var bla1 = document.getElementById("bla1");

bla1.insertItemAt(0, "ciao");

}


I set the listcell with id's as I thought that I could do


bla1.bla2.insertItemAt(0, "ciao");
bla1.bla3.insertItemAt(0, "ciao2");

but it does not work. I used the appendItem too but it didn't work.

Please someone help me with this problem.

Thanks


_______________________________________________
dev-tech-xul mailing list
dev-tech-xul@...
https://lists.mozilla.org/listinfo/dev-tech-xul

Re: How to insert item to a 2 columns listbox?!?!

by vladimir.dzhuvinov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Davide,

Code for appending elements normally looks like this:

// define XUL namespace
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/
there.is.only.xul";

// obtain your parent node
var listBox = document.getElementById("your-list-box");

// create the new elements
var newListItem = document.createElementNS(XUL_NS, "listitem");
var newCell1 = document.createElementNS(XUL_NS, "listcell");
var newCell2 = document.createElementNS(XUL_NS, "listcell");

// append the new elements in the proper order
listBox.appendChild(newListItem);
newListItem.appendChild(newCell1);
newListItem.appendChild(newCell2);



~ Vladimir
_______________________________________________
dev-tech-xul mailing list
dev-tech-xul@...
https://lists.mozilla.org/listinfo/dev-tech-xul

Re: How to insert item to a 2 columns listbox?!?!

by davide.sozzi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Aug 21, 9:41 am, vladimir.dzhuvi...@... wrote:

> Hi Davide,
>
> Code for appending elements normally looks like this:
>
> // define XUL namespace
> const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/
> there.is.only.xul";
>
> // obtain your parent node
> var listBox = document.getElementById("your-list-box");
>
> // create the new elements
> var newListItem = document.createElementNS(XUL_NS, "listitem");
> var newCell1 = document.createElementNS(XUL_NS, "listcell");
> var newCell2 = document.createElementNS(XUL_NS, "listcell");
>
> // append the new elements in the proper order
> listBox.appendChild(newListItem);
> newListItem.appendChild(newCell1);
> newListItem.appendChild(newCell2);
>
> ~ Vladimir



THX a lot :) it worked
_______________________________________________
dev-tech-xul mailing list
dev-tech-xul@...
https://lists.mozilla.org/listinfo/dev-tech-xul
LightInTheBox - Buy quality products at wholesale price!