DomAPI Home
DomAPI
Build: 4.0 BETA
Topic: Listgrid: setTopRow / selectRow

  scrasher registered v3 wrote on Monday 5/16/05 at 10:33 AM (PST)  
 

I'm trying to get the listgrid to scroll to the bottom on load. setTopRow and selectRow don't seem to be doing anything, but we might be using them incorrectly.

Any ideas?

We're basically trying to make the grid scroll to the bottom when the list is sorted down.

 
    RSS feed of forum  
  Darin Kadrioski registered v4 wrote on Monday 5/16/05 at 10:56 AM (PST)  
 

selectRow should be your guy, if you are passing the third optional argument:
selectRow(rowIndex, doSelect, makeCurrent)

Setting makeCurrent to true should cause the grid to scroll until the row is visible. This only works if the row is not already the 'current' row, and if it is not already in view.

setTopRow should also work - if you are still having trouble, please let us know a bit more about how you are doing it.

 
    RSS feed of forum  
  scrasher registered v3 wrote on Monday 5/16/05 at 2:20 PM (PST)  
 

I can't get it to work. Here's the code:

document.messageList=domapi.Listgrid({y:69,w:domapi.bodyWidth(),h:300,doVirtualMode:true,doRollover:true,doDepress:true,doBorder:false,doShowRowbar:false,doAllowNoS
election:false,doMultiSelect:true,doColResize:true,doAllowEdit:false,vertscrollbarvisible:true, gridlines: "none"});

document.messageList.loadFromJsonUrl("http://domain.com/data.txt");

document.messageList.bringToFront();
document.messageList.selectRow(30,true,true);
document.messageList.setTopRow(30);



data.txt looks like this:

{
cols : [
{ sortable : true, editable : false, fieldType : ftString, fieldName : "Field 1", value : 0, hidden: false },
{ sortable : true, editable : false, fieldType : ftString, fieldName : "R", value : 1, hidden: false },
{ sortable : true, editable : false, fieldType : ftString, fieldName : "Field 2", value : 2, hidden: false },
{ sortable : true, editable : false, fieldType : ftString, fieldName : "Field 3", value : 3, hidden: false },
{ sortable : true, editable : false, fieldType : ftString, fieldName : "Field 4", value : 4, hidden: false },
{ sortable : true, editable : false, fieldType : ftString, fieldName : "Field 5", value : 5, hidden: false }
],
rows : [

{ cells : [
{value : "field 1"},
{value : "field 2"},
{value : "field 3"},
{value : "field 4"},
{value : "field 5"},
{value : "fiend 6"}
], hidden: false },

<repeat 100x times>

{ cells : [
{value : "field 1"},
{value : "field 2"},
{value : "field 3"},
{value : "field 4"},
{value : "field 5"},
{value : "fiend 6"}
], hidden: false }

]
}

Yet the listgrid loads with the top row selected. Any ideas?

 
    RSS feed of forum  
  Jason Keirstead registered v4 wrote on Thursday 12/1/05 at 1:51 PM (PST)  
 

Any movement on this one? I can't get it to work either... the row ends up highlighted fine, but it's not scrolled into view. I'm using the non-virtual list grid.
window.table.setTopRow(rowIndex);
window.table.selectRow ( rowIndex, true, true );

Any thoughts?

 
    RSS feed of forum  
  Henry registered v4 wrote on Thursday 12/1/05 at 2:49 PM (PST)  
 

The key is to call refresh()

some code from the listgird manual test page. still trying to see how to put it back in to the listgrid. (Don't change the behavior of selectRow is very important)

function addRowSelected(bIndex) {
    addRow(bIndex);
    elm1.selectNone(); //<- need to do that clean up the display .... this                       //   do not make the grid paint properly, but enable the                       //   next line perform right    elm1.selectRow(elm1.data.getRowcount()-1,true,true); 
    elm1.currentRow = elm1.getRowsVisible()-1; //the selectRow didn't set currentRow correct                                               //thought set makeCurrent = ture.    elm1.currentCol = 0;
    elm1.refresh();
}



Henry
Addicted listgrid user.

 
    RSS feed of forum  
  Jason Keirstead registered v4 wrote on Friday 12/2/05 at 7:14 AM (PST)  
 

Seems that setting the currentRow and then calling the refresh method does the trick. Thanks.

 
    RSS feed of forum  
  Henry registered v4 wrote on Friday 12/2/05 at 9:17 AM (PST)  
 

but if you want to make sure the .selected contain the proper values you have to call selectRow also, I will submit a patch on this later on.

Henry

 
    RSS feed of forum  
You could respond to this post if you were logged in.
DHTML by www.domapi.com