:: Forum >>

Get contents of grid


How can I loop through the rows in a grid? I want to check if a row exists in the grid before I add it.

I've tried different variations of getCellText, none seems to work. I've tried getCellProperty("text") - doesn't seem to do anything.

I'm adding rows by using setCellText(row, index).

Any hints anyone?

Tuesday, February 28, 2006
You'll probably want to use a DISTINCT in your SQL select statement to make sure you are only getting one copy of each record. Checking the data every insert with a large dataset would be a real performance drag.
Tuesday, February 28, 2006

This is pure client-side - I'm just moving rows between two grids and I want the target grid to contain unique rows.

Wednesday, March 1, 2006
You can request an array of row indices from obj.getRowIndices() - if this method returns null then each row index is equal to row position (not sorted yet).

var obj = new AW.UI.Grid;

    obj.setCellText(function(i, j){return j + "." + i});


    var button = new AW.UI.Button;
    button.setControlText("Get rows");

    button.onClick = function(){

        var i, s = "";

        // request array of the row indices
        // if null then each index == position
        var a = obj.getRowIndices();

        for (i=0; i<obj.getRowCount(); i++){
            s += " " + (a ? a[i] : i);

Alex (ActiveWidgets)
Wednesday, March 1, 2006
There is a Complete working example at:
(this is actually my attempt at annotating and completing some of Alex earlier explanations of this)

If you play with this demo, you can get the full feel for how this works.
Perhaps not so obvious, untill you see it... If it can be inproved, let me know.

G. Cayman
Wednesday, March 1, 2006

This topic is archived.

Back to support forum

Forum search