I need some DataGrid performance help

zryip theSlug zryip.theslug at gmail.com
Wed May 6 07:58:08 EDT 2020


Paul,

After each call to a column property such as dgColumnWidth, the datagrid is
resized (header, column, rectangles, etc)

Instead of having them in the loop, prepare the column size, columns label,
etc and uses the table properties existing for setting all the values at
once. In this case the refresh of the datagrid is internally made only one
time.

Have a look in the datagrid properties documentation
http://lessons.livecode.com/m/datagrid/l/7343-data-grid-properties

for the table properties:
- column alignments
- column visibility
- column widths
- column labels

This is the only properties for table, because they have an impact in how
the datagrid is refreshed. The editable or the sort type of a column has
none. So even if you have a need of a loop, you can optimize it by removing
the tables properties.

An example for setting the widths of 3 columns at once

*set* the dgProp["column widths"] of *group* "DataGrid 1" to "100,200,300"


About column names. Internally they are used as keys for the dgData array.
Prefer shorter name without punctuation for column names and keep them only
for labels.


Best Regards,

On Wed, May 6, 2020 at 12:56 PM Pi Digital via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Hi Paul
>
> What handler do you have this code? From what you are saying it seems it’s
> deploying this formatting script every time it redraws which itself is very
> inefficient and unnecessary. It should only have to deal with the data
> itself ideally.
>
> Sean Cole
> Pi Digital Productions Ltd
>
>
> eMail Ts & Cs
>
>
> > On 5 May 2020, at 21:38, Paul Dupuis via use-livecode <
> use-livecode at lists.runrev.com> wrote:
> >
> > I have a datagid operation that should be fast that is taking a long
> time and I don't understand why.
> >
> > I use a datagrid to display a table of data as part of an analysis. The
> columns are file names and the rows are selected phrases found in those
> files. The first column is the list of phrases (162 in this example). The
> remaining columns are all the file name (254 in this example). So each cell
> (2 to 254) represents a count of the number of times the phrase (in column
> 1 of the row) was found the the file that column represents.
> >
> > I have the following code:
> >
> >   set the dgColumnWidth[tRowColumnName]      of grp
> "rwMatrixObj_DataGrid" to 200
> >   set the dgColumnAlignment[tRowColumnName]  of grp
> "rwMatrixObj_DataGrid" to "left"
> >   set the dgColumnSortType[tRowColumnName]   of grp
> "rwMatrixObj_DataGrid" to "text"
> >   set the dgColumnIsEditable[tRowColumnName] of grp
> "rwMatrixObj_DataGrid" to false
> >   repeat with i=2 to the number of lines in tColumnNames
> >     put line i of tColumnNames into tColumnName
> >     set the dgColumnTooltip[tColumnName]    of grp
> "rwMatrixObj_DataGrid" to tColumnName
> >     set the dgColumnWidth[tColumnName]      of grp
> "rwMatrixObj_DataGrid" to 75
> >     set the dgColumnAlignment[tColumnName]  of grp
> "rwMatrixObj_DataGrid" to "right"
> >     set the dgColumnSortType[tColumnName]   of grp
> "rwMatrixObj_DataGrid" to "numeric"
> >     set the dgColumnSortDirection[tColumnName] of grp
> "rwMatrixObj_DataGrid" to "descending"
> >     set the dgColumnIsEditable[tColumnName] of grp
> "rwMatrixObj_DataGrid" to false
> >   end repeat
> >
> > The first time this executes it takes just under 3 minutes for this size
> of data (254 columns). However, the second and each successive time in the
> same session it takes just under 30 minutes!
> >
> > Any idea why it would take so long?
> >
> > Thoughts on how to speed it up?
> >
> > I realize that I could use: 'set the dgProp["column widths"] of grp <DG>
> to <returnDelimitedListOfWidths>' as a single set action vs a loop where I
> am using 'set the dgColumnWidth[tColumnName] of grp <DG> to <singleWidth>'.
> >
> > However, there are only Datagid properties so set attributes for ALL
> columns for alignments, visibility, widths, and labels. Therefore, I have
> to use a loop anyway to set the tooltip, sorttype, sortdirection, end
> editability
> >
> > The column names (in the variable tColumnNames) are file names. Some are
> long (longest is 113 characters) and some contain assorted punctuation. I
> wonder is the column NAMES should be somehting plain ASCII and short and
> the column LABELS contain the file names?
> >
> > This is all in LiveCode 9.5.1 on Windows. Timing is approximately the
> same in a Standalone or the IDE.
> >
> > Anyway, if anyone has a good idea of what is taking this 30 minutes,
> ideas would be very welcome!
> >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


-- 
Zryip TheSlug
http://www.aslugontheroad.com



More information about the use-livecode mailing list