[CLOSED] Caching Dynamic Grids

Page 1 of 4 123 ... LastLast
  1. #1

    [CLOSED] Caching Dynamic Grids

    Hi,

    I am generating a lot of dynamic grids to display data based on database-driven configurations. Some of the grids I have contain some 40+ columns and constructing the grids everytime a page is hit takes some toll on the how fast the page loads.

    I was thinking of caching the grid - without the data - on the application level and have tried this :

        Application[gridName] = gridPanel;
    However, when i access the same page and tries to retrieve it from the cache, i get this error:

     Token is not unique
    -------------------
    ID = init_script
    TagName = anchor
    Match = <#:anchor id="init_script" />
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    
    Exception Details: Transformer.NET.TokenNotUniqueException: Token is not unique
    Is there a way to avoid this error and still make the caching work, the configuration for the grid doesnt change that too often.

    Thanks in advance,
    -Allan
  2. #2
    Hello!

    This is an interesting question. We will try to suggest you a solution.
  3. #3
    Are you sure the config generation is the slow part? usually it's the clientside DOM rendering that is slow. I doubt caching the server side object will save you anything.
  4. #4
    Quote Originally Posted by jchau View Post
    Are you sure the config generation is the slow part? usually it's the clientside DOM rendering that is slow. I doubt caching the server side object will save you anything.
    As I have said earlier, the grid configuration is database driven, the values on the database determines what is the type of field in the each column, eg.. text, date, or number, etc. Another thing being set from the database is if a particular column is editable, or if the column is a foreign key field, thereby generating a drop down of valid values. I also mentioned there are about 40 columns on average, some are hidden by default, most are not. These columns are dynamically generated and is pushed to the grid everytime a grid is requested.

    If i can cache the configured grid then it will save me a lot of load times in the process.
  5. #5
    Quote Originally Posted by Baidaly View Post
    Hello!

    This is an interesting question. We will try to suggest you a solution.
    Hi Baidaly,

    I have tried this code but i hit the same error:

    
                GridPanel gridPanel = new GridPanel();
                string gridKey = "MYCACHEDGRIDCONFIG";
                string gridConfig = string.Empty;
                if (Application[gridKey] == null)
                {
                    //configure grid panel here
                    gridPanel.Height = Unit.Pixel(500);
                    //.... some more configuration from the database;
    
                    gridConfig = gridPanel.ToConfig();
                    Application[gridKey] = gridConfig;
                }
                else
                    gridConfig = Application[gridKey].ToString();
    
                gridPanel = new GridPanel(GridPanel.Config.ToConfig<GridPanel.Config>(gridConfig));
                ViewPort.Items.Add(gridPanel);
  6. #6
    Hello,

    The "Token is not unique" exception means that several controls with the same ID are adding to the page. Is there such a possibility in your scenario?

    I feel it might be somehow related to the ToConfig call.

    I tried your code snippet, but I am getting this exception:
    Could not cast or convert from System.Int64 to System.Web.UI.WebControls.Unit.

    Are you not getting such an exception?
  7. #7
    Quote Originally Posted by Daniil View Post
    Hello,

    The "Token is not unique" exception means that several controls with the same ID are adding to the page. Is there such a possibility in your scenario?

    I feel it might be somehow related to the ToConfig call.

    I tried your code snippet, but I am getting this exception:
    Could not cast or convert from System.Int64 to System.Web.UI.WebControls.Unit.

    Are you not getting such an exception?
    Yes. I was getting that first error, then i tried to remove the Height config and it goes away, however, i have another error that somehow says the config string is using Json elements instead of Json arrays. I am not sure what it means. If you try removing the height config, and run it agaim, i am sure you will see the same error.

    Thanks,
    Allan
  8. #8
    Yes, there might be problems with deserialization into a Config class.

    I suggest the following. Create a GridPanel.Config instance until creating a GridPanel instance itself. Then you should be able to store a GridPanel.Config instance into Application and create a GridPanel without any problems.
  9. #9
    You should be caching your database configuration then and not the UI object.
  10. #10
    Quote Originally Posted by Daniil View Post
    Yes, there might be problems with deserialization into a Config class.

    I suggest the following. Create a GridPanel.Config instance until creating a GridPanel instance itself. Then you should be able to store a GridPanel.Config instance into Application and create a GridPanel without any problems.
    Is there a way you can give me a sample code on how to do this? I have this code and it doesn't render the grid properly. I am testing on simple configurations first:

                GridPanel.Config config = new GridPanel.Config();
    
                Model model = new Model();
    
                for(int i = 0; i < 10; i++)
                {
                    Column col = new Column();
                    col.Text = "Column" + i.ToString();
                    col.Width = Unit.Pixel(200);
                    col.DataIndex = "Column" + i.ToString();
    
                    config.ColumnModel.Add(col);
    
                    ModelField field = new ModelField();
                    field.Name = "Column" + i.ToString();
                    model.Fields.Add(field);
                }
    
    
                Store store = new Store();
                store.Model.Add(model);
    
                config.Store.Add(store);
    
                 GridPanel gridPanel = new GridPanel(config);
                 ViewPort.Items.Add(gridPanel);
Page 1 of 4 123 ... LastLast

Similar Threads

  1. [CLOSED] Ext.select caching problem
    By fpw2377 in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jul 12, 2012, 10:43 AM
  2. [CLOSED] Drag & Drop Between Dynamic grids
    By imaa in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Dec 05, 2011, 12:34 PM
  3. [CLOSED] Caching the ResourceManager/ExtJs library
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Feb 13, 2011, 12:51 PM
  4. [CLOSED] Desktop application caching of web pages
    By ogokgol in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 08, 2011, 8:39 AM
  5. [CLOSED] How to turn on resource caching?
    By jchau in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 28, 2009, 7:01 PM

Tags for this Thread

Posting Permissions