Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Lazy Rendering vs Lazy Loading

    We have a RestDataSource defined for the data I want to display in the grid which can display about 30 records on the screen at a time.
    We have added filterEditor to the grid data to filterOnKeyPress().
    We have about 7000 records coming from the exist database.


    We are facing 2 major problems:

    1) We checked the time the server takes to send the data back to the client and its minimal. But after getting the data, it takes time for the grid to display all of dem. There is a significant lag of about 45 secs to a min. We want to get rid of this lag as after that using the filters to filter on client side data works with awesome speed as there are no server calls anymore.

    2) We have tried lazy loading to overcome the lag. About 25 rows are returned on each call but using the drawAheadRatio we allow about 300 records to be fetched and cached. So yes the intial load is become considerably fast. So now as I scroll down the grid we can see server calls being made to fetch more data. But now the interactivity is lost and even the filter doesnt work as it makes a call to the server everytime a value on the filter is changed. So client-side filtering is lost and it expects the server to do the filtering which I have not implemented yet. Even if I do implement it would mean that if I have 5 fields that provide filtering I have to make 5 calls to the server so that all criteria fields are considered. Thats nt good.

    What I want is get all possible data from the server in a call which is fast in my case but speed up grid loading like showing the first 30 records shudnt be slow. Also, I want the filters to work on client side data rather than asking the server to sort or filter... I want the smartgwt client to do it which makes me conclude that its possible only if the client has all the data it needs cached wid it.

    That brings another question on caching. How does caching of data take place when lazy loading is implemented???


    Answers to these questions would really help me design my application better for better interactivity and faster processing.

    Thanks,
    Hetal

    #2
    Hello Hetal,

    You can get 7000 records into the browser and do relatively responsive client-side filtering (still very fast in Safari) if you really need to, but, it's best to circumvent some layers for speed reasons if this is a hard requirement.

    For starters use the JSON format with RestDataSource, which is faster.

    The fastest possible client-side performance would come from delivering the data as a JSON string, eval()'ing it client-side, and providing it as testData to a clientOnly DataSource *via a JSNI call*. This avoids any code that has to iterate over records to, for example, convert date strings into Date objects.

    Comment


      #3
      Should also mention, depending on what kind of application you're building, delivering 7000 records all at once might be a very bad choice. The database responds quickly in testing when only one user is running the application, but this may not be the case in production if you have many users. In that case it may be better that server side filtering is used until the number of records is smaller, and then client-side filtering kicks in, which is SmartGWT's default behavior.

      Comment


        #4
        Thank you for ur reply.

        I understand your suggestion for faster retrieval. And we have implemented that.. and it is fast, but what I dont like about this approach is at every scroll it displays a message, fetching data from the server... which is annoying sometimes.. somehow I rather atleast not see it contact the server after the first retrieval.

        Kindly clear one small doubt.. Lazy Loading involves going back to the server to fetch remaining data. When we say Lazy Rendering is done, what happens exactly on the client-side or is it a server side operation??? Does it involve some explicit mentioning on the client side to the grid or datasource that setLazyRendering to true or something like that?? Or does it mean that grid by default does lazy rendering once it gets all records.

        Thanks so much for ur replies before.
        Hetal

        Comment


          #5
          That message is called the "prompt". It can be disabled globally or per-DataSource or per-request - see the docs.

          Lazy rendering means that HTML is only created for the current visible rows, and is re-created each time new rows are scrolled into view.

          Comment


            #6
            I submited an issue about this message prompt thing, as I need it also:
            http://code.google.com/p/smartgwt/issues/detail?id=193

            meanwhile this code works ok:

            Code:
            private class MyDataSource extends DataSource {
            		
            	public void setShowPrompt(boolean option) {
            		setAttribute("showPrompt", option, true);
            	}
            	
            }

            Comment

            Working...
            X