draganndi
draganndi

Reputation: 155

How to get the position(col, row) of the user changed cell in a Table control?

I'm using tutorial_Form_Table.

The table has dynamically assigned values, something like:

for (col = 1; col <= 5; col++)
{
    for (row = 1; row <= 5; row++)
    {
        if ((col == 2) || (col == 4))
        {
            if (row > 1)
                table.cell(col,row).data(row*col);
            else
                table.cell(col,row).data("Text "+int2str(row*col));
        }
        else
            table.cell(col,row).data("Text "+int2str(row*col));
    }
}

Table

I need to get the position of the cell when I enter new value in it, so I can update the corresponding table with the value entered.

Thank you.

Upvotes: 0

Views: 1425

Answers (1)

Anže Krpič
Anže Krpič

Reputation: 265

Table has two properties: row() and column() which return values of current active cell.

public void activeCellChanged()
{
    super();
    info(strFmt('%1 %2 %3', Table.row(), Table.column(), Table.cell(Table.column(), Table.row()).data()));
}

On each of the controls you add to the table control you can override the modified method to see the new value you entered.

public boolean modified()
{
    boolean ret;

    ret = super();

    info(strFmt('New data that we need to save: %1, %2 -> %3', Table.row(), Table.column(), Table.cell(Table.column(), Table.row()).data()));

    return ret;
}

If you are working with a lot of data you should consider using some other control such as .NET grid control because of performance issues.

Upvotes: 3

Related Questions