Farbflash projects: Imaging lingo table | 3-D scene list | Find all | Handler menu | Lingo message window
wiki:FAQ1
Last modified 4 years ago Last modified on 10/02/07 15:03:56

Back to Documentation

FAQ 1

How do I refresh a cell I just changed?

mRefreshItem (cellRef)

<cellRef> is a reference to the cell we want to update.

This method is missed in the documentation, but will avoid you to redraw the whole table when changes limit to only part of it. It was really usefull when drawing a very large table with images. I could do it asynchronously, so giving inmediate feedback to the user.

While mRefreshItem is kind of a "private" method of the DrawTable script object, the exposed "public" method to change a cells content is mSetCellContent which you will find in the behavior "TableManager" (exposed through "TableManagerHost" in the protected version). "mSetCellContent" will take care of refreshing the cell and recalculating columns, if necessary. It can take up to 5 parameters:

parameterformatrequirementnotes
rowintegerrequiredtable row
columnintegerrequiredtable column
newValuewhatever the type of the cells content isrequirednew content for the cell
relativeboolean (integer)optional (default = false)whether the values for row and columns are treated absolute or relative (sorting or filtering may change the order)
recalcboolean (integer)optional (default = true)recalculate columns widths (time consuming as every cell in the column must be rendered)
tablenamestringoptional (default = tablelist[1])name of the table (only necessary if behavior hosts more than one table => 3-D sprite)

In order to change the seleected, the highlight or the enabled state of a cell use the methods:

  • mSetSelection
  • mSelectCell
  • mHighLightCell
  • mEnableCell

Having said all that, I confess, that there are rare cases, where I use the "private" mRefreshItem method myself. Especially on callbacks from the table object, as I get a handle to the cell and a handle to the table object and so it is easier to set the content and refresh the cell directly. But keep the following comment found in the script in mind:

-- render only one single cell, after changing its properties (e.g. #selected) NOT the #content property !!!
-- after changing the content of a cell call rather 'mRefreshCellContents()' to take a change of lineheight into consideration
-- of course, if you change the content of a cell and don't want the dimension of the cell to change you can go with this function, much faster..

mRefreshCellContents takes a cell reference an integer for width change of the cell. This is another private method and should not been used directly. You should really use the public methods instead.