3.2.0

How to get the row no in grid

I have to select multiple rows to perform some operation and need the row no of the rows selected by user. Any suggestions?
Jack
April 5,
You can get the array of the selected row indices with getSelectedRows() method (or as an argument in onSelectedRowsChanged event). The row number (position from the top in the current order) could be obtained with getRowPosition(rowIndex) method.

var obj = new AW.UI.Grid;
    obj.setCellData(function(col, row){return col + "." + row});
    obj.setHeaderText("header");

    obj.setColumnCount(10);
    obj.setRowCount(10);

    obj.setSelectionMode("multi-row");

    obj.onSelectedRowsChanged = function(rowIndexArray){

        var rowIndex, rowPosition, i, s = "";

        for(i=0; i<rowIndexArray.length; i++){
            rowIndex = rowIndexArray[i];
            rowPosition = this.getRowPosition(rowIndex);
            s += " " + rowPosition;
        }

        window.status = s;
    }

    document.write(obj);
Alex (ActiveWidgets)
April 5,
Thanks
Jack
April 5,

This topic is archived.

See also:


Back to support forum