3.2.0

How to select and highlight first row?

I am trying to have the first row of my grid selected and highlighted.
I am confused about all the various functions for make a row "current", "selected", and the "state" of a cell in a row.

I found that grid.setCurrentRow and grid.setSelectedRows() do not actually highlight the row. But grid.setCellState("selected", col, row) does.

How do I do this correctly?
Derek Capple
October 10,
To highlight the row it should be enough to call

grid.setSelectedRows([0]);

To make the row current (for keyboard movements) call

grid.setCurrentRow(0);

All that requires setting selection mode to "single-row" as the default selection mode is single cell and selecting the full row will not work in that mode.

grid.setSelectionMode("single-row");

There is also a bug in 2.0.1 which scrolls the grid one row up hiding the first row.

Here is the complete code :-)

obj.setSelectionMode("single-row");
obj.setSelectedRows([0]);
obj.setCurrentRow(0);
obj.setScrollTop(0);
Alex (ActiveWidgets)
October 11,
Hi Alex, I´v trying to set the first row after load a CSV data, but I didn´t. I tried the onRowAdded method, response method, setProperty, setSelectionProperty but no one works for me.
My code is this:

var iTable = new AW.CSV.Table;
iTable.setURL("modules/modules.csv");
iTable.request();
var columns = ["ID","Module","Description","Father Mod"];

var iGrid = new AW.UI.Grid;
with(iGrid){
var str = new AW.Formats.String;
var num = new AW.Formats.Number;

setId("grid");

setColumnWidth(50, 0);
setColumnWidth(130, 1);
setColumnWidth(165, 2);
setColumnWidth(130, 3);

setStyle("height", "100px");
setStyle("width", "520px");

setHeaderText(columns);
setColumnCount(4);
setCellFormat([num,str,str,str]);
setSelectorVisible(true);
setSelectorText(function(i){return this.getRowPosition(i)+1});
setSelectorWidth(25);
setSelectionMode("single-row");

setCellModel(iTable);
setSelectedRows([1]);
setCurrentRow(1);
setScrollTop(1);
};
Wesley Milan
October 19,
I´m sorry, this exemple is to select the second row, but the case is, the setSelectedRows([1]); try to select the row before the data is loaded.
Wesley Milan
October 19,

This topic is archived.

See also:


Back to support forum