datagrid: add rows in CloseFieldEditor

Trevor DeVore lists at mangomultimedia.com
Fri Dec 31 10:46:32 EST 2010


On Thu, Dec 30, 2010 at 4:23 PM, JosepM <jmyepes at mac.com> wrote:

>
> > To reference to next row from the actual is better use
> >
> > SetDataOfIndex the dgindex of me+1, "COL1", "Text of the Col"
> >
> > or can be a problem with datagrid index?
>
>  <Hmm, I think this might cause problems. The data grid won't throw an
> error
> <if you try to assign data to an index that you haven't added but I also
> <don't think it will update the total height of the data in the grid which
> <AddData will do. This may cause problems when scrolling through your data
> <later on.
>
> Whenever I refer to the other line is why I have the certainty that there
> is, so the first row generates, if necessary, additional lines. So, in
> theory should not cause any error.
>
> I have been trying to create several rows which this create more rows to
> force the displacement of the datagrid height and, at first glance seems to
> work and move correctly.
>
> The creation of these lines is always in last position and never between.
>
> Why you say that don't update de total height of data?
>

The data grid has to keep track of the total height of the data in a data
grid. For a data grid table or a data grid form with a fixed row height this
is just the row height * the number of records in the table. For data grid
form with variable row heights the total height is cached. This cache is
updated when you add/remove rows. If you use SetDataOfIndex to add a row to
a data grid form with variable row heights then the cached height would not
be correct.

I just looked at the code again and there are other operations that occur
when adding a row to a data grid such as storing of the sequence for the
index. So I would recommend that you always use AddData to add rows to the
data grid.

-- 
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
Releasable Revolution Resources for Developers:
http://revolution.bluemangolearning.com



More information about the use-livecode mailing list