DataGrid: load images when in view

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

DataGrid: load images when in view

Richard Gaskin via use-livecode
Greetings!

Say you have a form DataGrid that is displaying 100 entries.  Each entry has an image (loaded from a server) and some text.  When you set the dgData, it will get all 100 images as it's building the rows.  This is obviously going to take some time to load.  Is there a way to have the DataGrid only load the row's image when that row comes into view?  This way it will load the images as they are needed.

Thanks in advance!
-Dan

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: DataGrid: load images when in view

Richard Gaskin via use-livecode
Hi Dan,

To begin, using the NUmberOfRecordsProperty cancels out all performance
issues with the dg.  Using this method enables exactly what you are asking
for.

On Fri, Nov 8, 2019 at 12:29 PM Dan Friedman via use-livecode <
[hidden email]> wrote:

> Greetings!
>
> Say you have a form DataGrid that is displaying 100 entries.  Each entry
> has an image (loaded from a server) and some text.  When you set the
> dgData, it will get all 100 images as it's building the rows.  This is
> obviously going to take some time to load.  Is there a way to have the
> DataGrid only load the row's image when that row comes into view?  This way
> it will load the images as they are needed.
>
> Thanks in advance!
> -Dan
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


--
Tom Glod
Founder & Developer
MakeShyft R.D.A (www.makeshyft.com)
Office:226-706-9339
Mobile:226-706-9793
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: DataGrid: load images when in view

Richard Gaskin via use-livecode
But then you need to manage populating the visible records of the grid by script, right?

Bob S


> On Nov 8, 2019, at 10:54 , Tom Glod via use-livecode <[hidden email]> wrote:
>
> Hi Dan,
>
> To begin, using the NUmberOfRecordsProperty cancels out all performance
> issues with the dg.  Using this method enables exactly what you are asking
> for.


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: DataGrid: load images when in view

Richard Gaskin via use-livecode
In reply to this post by Richard Gaskin via use-livecode
Dan Friedman wrote:

 > Say you have a form DataGrid that is displaying 100 entries.  Each
 > entry has an image (loaded from a server) and some text.  When you
 > set the dgData, it will get all 100 images as it's building the rows.
 > This is obviously going to take some time to load.  Is there a way
 > to have the DataGrid only load the row's image when that row comes
 > into view?  This way it will load the images as they are needed.

That's how the DG works, by design, and the main reason for using it
over a collection of nested groups.

The DG will only populate rows as they are brought into view.  At any
given time the number of rendered rows = the number of visible rows.

I once made a media browser that allows access to 2600 images, and the
DG handled it like a champ.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: DataGrid: load images when in view

Richard Gaskin via use-livecode
If he only queries for the data for the visible records. Otherwise the query is going to take as long as it takes to DL all the data.

I was thinking some time ago about developing some paging scripts for the datagrid, using the LIMIT function of SQL, but I never actually had a reason for it. Also it dawned on me that I could not use findRecord or findIndex on a limited range of the data contained in the dgData.

I have a datagrid that loads file data as in saved fillable form PDFs stored in large BLOB columns, and when I got to 15 forms or so, and I was on a slow connection, working with the Forms module took a substantial time to load all the data.

What I did instead is just before making the query I deleted the column containing the form data from the select clause, so I only queried for columns not containing large amounts of form data. I query for the form data only when needed.

Bob S


> On Nov 8, 2019, at 12:25 , Richard Gaskin via use-livecode <[hidden email]> wrote:
>
> Dan Friedman wrote:
>
> > Say you have a form DataGrid that is displaying 100 entries.  Each
> > entry has an image (loaded from a server) and some text.  When you
> > set the dgData, it will get all 100 images as it's building the rows.
> > This is obviously going to take some time to load.  Is there a way
> > to have the DataGrid only load the row's image when that row comes
> > into view?  This way it will load the images as they are needed.
>
> That's how the DG works, by design, and the main reason for using it over a collection of nested groups.
>
> The DG will only populate rows as they are brought into view.  At any given time the number of rendered rows = the number of visible rows.
>
> I once made a media browser that allows access to 2600 images, and the DG handled it like a champ.
>
> --
> Richard Gaskin
> Fourth World Systems
> Software Design and Development for the Desktop, Mobile, and the Web


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: DataGrid: load images when in view

Richard Gaskin via use-livecode
I forgot to finish my thought. What Tom could do is query for ALL the data, excepting the image data, then have a custom script that loads the images for just the visible records. This would preserver the ability to use findRecord and findIndex on the full set of the already queried and stored data in the datagrid, while maintaining efficiency for the visible images.

Bob S


> On Nov 8, 2019, at 12:58 , Bob Sneidar via use-livecode <[hidden email]> wrote:
>
> If he only queries for the data for the visible records. Otherwise the query is going to take as long as it takes to DL all the data.
>
> I was thinking some time ago about developing some paging scripts for the datagrid, using the LIMIT function of SQL, but I never actually had a reason for it. Also it dawned on me that I could not use findRecord or findIndex on a limited range of the data contained in the dgData.
>
> I have a datagrid that loads file data as in saved fillable form PDFs stored in large BLOB columns, and when I got to 15 forms or so, and I was on a slow connection, working with the Forms module took a substantial time to load all the data.
>
> What I did instead is just before making the query I deleted the column containing the form data from the select clause, so I only queried for columns not containing large amounts of form data. I query for the form data only when needed.
>
> Bob S


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: DataGrid: load images when in view

Richard Gaskin via use-livecode
In reply to this post by Richard Gaskin via use-livecode
Bob Sneidar wrote:

> On Nov 8, 2019, at 12:25 , Richard Gaskin via use-livecode wrote:
>> The DG will only populate rows as they are brought into view.
>> At any given time the number of rendered rows = the number of
>> visible rows.
>>
>> I once made a media browser that allows access to 2600 images,
>> and the DG handled it like a champ.
>
> If he only queries for the data for the visible records.
> Otherwise the query is going to take as long as it takes
> to DL all the data.

True dat.

In our app we solved that problem easily enough, since we only needed
thumbnails for the list view:

Each of those was less than 200px, and after a little experimenting I
found that lowering the jpegQuality just a bit when creating those
thumbnails lowered file size significantly.

Then I packed all 2600 images into an array keyed by file name, encoded
and zipped it.

The result was a single LSON.gz archive that weighed in at about 1.5
MBs, and came over the wire in seconds.  Took about as long as the data
file that references those images.

Our row populating routine used the array to set the thumbnail in the
DG.

Later when we added a feature to allow image uploads, we added a routine
to keep the thumbnail archive up to date along with the full-sized
master.

In four years of production it ran like a champ, seriously outperforming
a similar tool made by another department in Java (at much greater
expense).  It's not that Java itself is slower, but just that LC's
flexibility let us be more clever. :)

--
   Richard Gaskin
   Fourth World Systems
   Software Design and Development for the Desktop, Mobile, and the Web
   ____________________________________________________________________
   Ambassador at FourthWorld.com                
http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode