[Project_owners] listbox strange behavior?

MacCpp maccpp at yahoo.com.ar
Mon Jan 31 12:29:55 EST 2005


Rod Whiteley wrote:

> MacCpp wrote:
>
>> Anybody tried to add dinamically a row in a listbox...
>
>
> When I use the listbox's own appendItem method to add a row at the 
> bottom where I cannot see it without scrolling, there is no problem.  
> I can still see the top row that is selected by default.
>
> Perhaps you can explain your problem some more, or make a simple XUL 
> test file that reproduces it in a browser.
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>
Well, here are the files, they will explain the problem better than me 
;)..... It is ok, when the new row is added in the visible portion of 
the list, but when I follow adding..... and the new ones are added and I 
scroll to see them, I can not see the first column. I know that I am 
making a mistake, but yet I can not find it. Again, thanks.
The xul portion is:
    <listbox id="scoList" flex="1">

      <listcols>
        <listcol id="col0" flex="1"/>
        <listcol id="col1" flex="1"/>
        <listcol id="col2" flex="1"/>
    <listcol id="col3" flex="1"/>
    <listcol id="col4" flex="1"/>
      </listcols>

      <listhead>
        <listheader label="Sco Item"/>
        <listheader label="Sco Path"/>
        <listheader label="Sco Base Folder"/>
        <listheader label="Sco Folder"/>
        <listheader label="Sco Title"/>
      </listhead>

    </listbox>
and the js is:
function fillInScoList ( )
{
  alert ( aScoList .length );
  for ( var i = new Number ( 0 ) ; i < aScoList . length ; i ++)
  {
    var scoList = window . document . getElementById ( 'scoList' );

    var text = window . document . createElement ( 'textbox' );
    text . setAttribute ( "id", "text_scoTitle_" + String ( i ) );
   
    var label1 = window . document . createElement ( 'label' );
    var label2 = window . document . createElement ( 'label' );
    var label3 = window . document . createElement ( 'label' );

    label1 . setAttribute ( "id", "label_1_" + String ( i ) );
    label1 . setAttribute ( "crop", "end" );
    label1 . setAttribute ( "value", aScoList [ i ] . realFolder );

    label2 . setAttribute ( "id", "label_2_" + String ( i ) );
    label2 . setAttribute ( "crop", "end" );
    label2 . setAttribute ( "value", aScoList [ i ] . baseFolder );

    label3 . setAttribute ( "id", "label_3_" + String ( i ) );
    label3 . setAttribute ( "crop", "end" );
    label3 . setAttribute ( "value", aScoList [ i ] . scoFolder );

    var cell1 = window . document . createElement ( 'listcell' );
    var cell2 = window . document . createElement ( 'listcell' );
    var cell3 = window . document . createElement ( 'listcell' );
    var cell4 = window . document . createElement ( 'listcell' );

    cell1 . appendChild ( label1 );
    cell2 . appendChild ( label2 );
    cell3 . appendChild ( label3 );
    cell4 . appendChild ( text   );


    var item = scoList . appendItem ( "sco" + String ( i ) ); // this 
is, the default cell, sometimes I see it well, but not always

    item . appendChild ( cell1 );
    item . appendChild ( cell2 );
    item . appendChild ( cell3 );
    item . appendChild ( cell4 );
  }
}



More information about the Project_owners mailing list