Sqlite and performances in LiveCode
pete at mollysrevenge.com
Wed Mar 14 20:35:32 CDT 2012
Sorry to keep coming up with new quirks but I have another strange
situation regarding GetDataForLine.
Under some circumstances, the data that I supply from GetDataForLine ends
up in the datagrid starting at the 13th line instead of line 1 and the
first 12 lines have data in them from the previous cycle of GetDataForLine.
One GetDataForLine cycle deals with 12 lines.
I'm using the datagrid in question as a general purpose viewer of data from
any table in an sqlite database. The circumstances that cause the problem
are if I have data from a table displayed, then I filter it in some way, so
the number and format of the dg columns is the same but the rows contain a
subset of the original data. If I select a different table and therefore
change the number and size of the dg columns, the correct data is displayed.
I set a breakpoint at the end of GetDataForLine and can see that I am
sending the correct data back to the datagrid in pDataA and pline starts at
1 and continues correctly up to 12.
If I refresh the datagrid either from its Inspector palette or by script,
the correct data turns up at the top of the datagrid although that invokes
another cycle of GetDataForLine.
Also, if I scroll down the datagrid past the 12th line then scroll back to
the top of the datagrid, the correct data turns up. If I scroll less than
12 lines then back, some of the incorrect lines still appear and the the
rest of the lines are correct. For example, if I scroll down 4 lines then
back, the first 4 lines have incorrect data and the rest are correct.
It seems like this must be something I'm doing wrong in my code but the
fact that I see the correct data being sent to the datagrid for the correct
line from GetDataForLine seems to argue against that.
Can you think of anything that might cause this behavior?
On Wed, Mar 14, 2012 at 7:05 AM, Trevor DeVore <lists at mangomultimedia.com>wrote:
> On Tue, Mar 13, 2012 at 5:46 PM, Pete <pete at mollysrevenge.com> wrote:
> > OK, found the problem. I had a set dgProps["sort by column"] statement
> > after setting the dgNUmberOfRecords. Moved that to a place where
> > dgNumberOfRecords is zero and only one cycle of GetDataForLine happens
> Great. Just remember that anytime a redrawing of the data grid has to occur
> (e.g. when changing sorting) GetDataForLine has to be called.
> > Thanks for the help in tracking it down. There are a lot of nuances
> > to using dgNumberOfRecords!
> Yes there are. GetDataForLine is a (bolted on) means of providing an
> approach that separates the control from the data so the data doesn't
> reside within the view control itself. The API for the data grid was built
> around the standard LiveCode control behavior where the data resides within
> the control.
> There really is room for a data grid-like control that is really just a
> view and does nothing more than display data that is fed to it from a data
> Trevor DeVore
> Blue Mango Learning Systems
> www.clarify-it.com - www.screensteps.com
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
Molly's Revenge <http://www.mollysrevenge.com>
More information about the use-livecode