[CLOSED] Caching Dynamic Grids

Page 3 of 4 FirstFirst 1234 LastLast
  1. #21
    Hi Vladimir,

    I understand what you are saying. I was trying to cache the config. so I can rebuild the grid using the config. However, it can not be done as well. As there is a serialization issue of caching the config back and forth. This is something that needs to be addressed (in my opinion). Because the ToConfig() call is a string. And I see no reason why it can not be cached.

    Now, the reason why I am trying to cache the grid, because the config caching fails, and I have no other option. I am consulting this forum to give me an alternative to that since, as you have said, caching the actual control is a NO-NO. However, I have not acquired a definite solution to my issue. In my earlier post, it is clear that there is some problems with serializing the config back and forth and building the grid again. Even without caching, these lines does not work :

    
    string config = gridPanel.ToConfig();
    
    GridPanel newGrid = new GridPanel(GridPanel.Config(config));
    ViewPort.Items.Add(newGrid);
    There is no caching here. It is just plain serialization of the config. And it doesn't work. If this will work, then I can cache the string and my initial issue can be resolved. The solution of caching the control was a secondary alternative to this very first problem, which the support team acknowledges (see previous posts on this thread) but offered no solution.

    Thanks,
    Allan
  2. #22
    Because the ToConfig() call is a string. And I see no reason why it can not be cached.
    Yes, string can be cached. But how you will use that string?
    Probably, you misunderstod what ToConfig method do. It serialize (render) control to json object representation. That object can be used to create client side instance (javascript instance), just passing to client side constructor. It cannot be used on server side somehow.

    In my earlier post, it is clear that there is some problems with serializing the config back and forth and building the grid again.
    Control can be serialized (means rendered) but cannot be deserialized because there is no rendering reverse operation. Also, GridPanel.Config constructor doesn't accept any arguments therefore your code (new GridPanel(GridPanel.Config(config))) is not compilable at all.

    The solution of caching the control was a secondary alternative to this very first problem, which the support team acknowledges (see previous posts on this thread) but offered no solution.
    Can you post link to that post? What exactly problem do you mean? If you mean first post from this thread then I should say that:
    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.
    Creating controls cannot be issue at all. Issue can be related with data extracting from DB, issue can be related with controls rendering (like if store has huge data for serializing). Threfore I am not sure why do you think that caching controls instansec can solve something

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

    1 Application[gridName] = gridPanel;


    As I said, controls cannot be cached. Also, application is global object therefore if 'gridName' key is not unique for each user then one user grid will replace another user grid in Application object.

    However, when i access the same page and tries to retrieve it from the cache, i get this error:
    I guess the error reason is that control cannot be rendered many times for serveral page instances (you cache control and render it for different request which is inadmissible). In any way, if you post runable test sample the we will review it to ensure that issue is related with caching only (to exclude possibility that it is Ext.Net bug)
  3. #23
    I posted the wrong code earlier, this is what i meant:

    GridPanel gridPanel = new GridPanel();
    string gridConfig = string.Empty;
    
    //configure grid panel here
    gridPanel.Height = Unit.Pixel(500);
    
    //.... some more configuration from the database;
     
     gridConfig = gridPanel.ToConfig();
     
    gridPanel = new GridPanel(GridPanel.Config.ToConfig<GridPanel.Config>(gridConfig));
    ViewPort.Items.Add(gridPanel);
    As i have said over and over, I do not intend to cache controls. I need a way to cache the configuration so i dont have to build the grid again every time.

    I understand that you are saying this can not be done?

    Thanks,
    Allan
  4. #24
    I need a way to cache the configuration so i dont have to build the grid again every time.
    You need to build a grid in any way (even configuration is cached). You have to create any business object which stores grid's configuration/schema (describes what columns should be added, which store store fields and etc) and cache that object. Format of that bussines object is free (you can add any required properties). According that object you need to create control instance each time whent it is required. Caching business object which describes instance configuration makes in one case, when retrieving data for that config object is long/resourceable operation.
  5. #25
    Quote Originally Posted by Vladimir View Post
    You have to create any business object which stores grid's configuration/schema (describes what columns should be added, which store store fields and etc) and cache that object.
    As i have mentioned again earlier, that object is already in cache. The long process is trying to create the column based on that object :
    private void RenderGridMe()
    {
        //THIS IS CACHED ALREADY. THIS IS CACHED ALREADY. THIS IS CACHED ALREADY. THIS IS CACHED ALREADY
        List<Entity> columns = Application["TESTCOLUMNS"];
     
        GridPanel gridPanel = new GridPanel();
     
        //I WANT TO SKIP THIS PROCESS BECAUSE THIS IS THE ONE TAKING SO LONG..
        // IS THERE A WAY TO REMEMBER THIS AFTER GOING THOUGH IT THE FIRST TIME?
       //I BELIEVE ALL THESE INFO ARE ALREADY ON THE GridPanel.Config
        foreach (Entity column in columns) // COLUMNS IS ON AVERAGE 40 items.
        {
            switch (column.DataType)
            { 
                case "date":
                case "datetime":
                    gridPanel.ColumnModel.Columns.Add(CreateDateColumn(column));
                    break;
    
                case "text":
                case "string":
                    gridPanel.ColumnModel.Columns.Add(CreateTextColumn(column));
                    break;
     
                case "int":
                case "bigint":
                case "integer":
                    gridPanel.ColumnModel.Columns.Add(CreateNumberColumn(column));
                    break;
    
                default:
                    gridPanel.ColumnModel.Columns.Add(CreateTextColumn(column));
                    break;
            }
        }
       //END OF I WANT TO SKIP
     
        ViewPort.Items.Add(gridPanel);
    }
     
    private Column CreateNumberColumn(Entity entity)
    {
        //Do the configuration again here...
    }
    
    private Column CreateTextColumn(Entity entity)
    {
        Column column = new Column();
        string label = entity.Label;
        string format = entity.Format;
     
        column.Text = entity.Title;
        column.Sortable = true;
     
        if(entity.Width == 0)
             column.Flex = 1;
        else 
             column.Width = Unit.Pixel(entity.Width);
    
        column.DataIndex = entity.DataColumn;
        column.Groupable = false;
     
        if (entity.Editable)
        {
            Ext.Net.TextField textField = new Ext.Net.TextField();
            column.Editor.Add(textField);
        }
     
        return column;
    }
    
    private DateColumn CreateDateColumn(Entity entity)
    {
        DateColumn column = new DateColumn();
        string label = entity.Label;
        string format = entity.Format;
     
        column.Text = entity.Label;
        column.Sortable = false;
        column.Width = Unit.Pixel(100);
        column.MaintainFlex = true;
        column.DataIndex = entity.DataColumn;
        column.Groupable = false;
     
        if (entity.Editable)
        {
            Ext.Net.DateField dateField = new Ext.Net.DateField();
            dateField.Format = format;
            column.Editor.Add(dateField);
        }
     
        if (!string.IsNullOrWhiteSpace(format))
            column.Renderer.Fn = ("Ext.util.Format.dateRenderer('" + format + "')");
     
     
        return column;
    }
  6. #26
    //I WANT TO SKIP THIS PROCESS BECAUSE THIS IS THE ONE TAKING SO LONG..
    // IS THERE A WAY TO REMEMBER THIS AFTER GOING THOUGH IT THE FIRST TIME?
    //I BELIEVE ALL THESE INFO ARE ALREADY ON THE GridPanel.Config
    I don't see what can be long in the column creating. Do you think that creating instance of control is long operation? I don't think so. For example, what can be long in CreateTextColumn code?
    Skiping column creation doesn't give you any advantages and it is not possible (any control must be rectreated for new request)
  7. #27
    Quote Originally Posted by Vladimir View Post
    I don't see what can be long in the column creating. Do you think that creating instance of control is long operation? I don't think so. For example, what can be long in CreateTextColumn code?
    Skiping column creation doesn't give you any advantages and it is not possible (any control must be rectreated for new request)
    Hi Vladimir,

    The process of creating 6 grids with an average of 40 columns each grid on a page, takes about 82 seconds. If skipping this will NOT give me an advantage, tell me which one will?

    All I got from here is that caching the UI is WRONG. With UI caching, i was able to bring it down to 12 seconds. I came here to look for a better approach on how to do this, instead, i got criticisms on the current approach but NO recommendation on how to actually do it right.

    So, please ignore this, since, i feel we are just both wasting our time. There is an issue in serializing the GridPanel.Config which was acknowledged earlier and that you are trying to avoid acknowledging now.

    Thanks for your time.
  8. #28
    The process of creating 6 grids with an average of 40 columns each grid on a page, takes about 82 seconds. If skipping this will NOT give me an advantage, tell me which one will?
    82 seconds? It is absolutely abnormal if we forget about cache question, even single operation which takes 82 sec is not good. Just imagine that the page is loaded 82 sec

    I can create quick test case (6 grids with 40 columns in each) and it will be executes in milliseconds. You have to profile your code and find what causes so long process. It is definitely not Ext.Net code. Do you have any DB operations? If yes then you need to cache DB operations (instead whole grid creation cache)
  9. #29
    I came here to look for a better approach on how to do this, instead, i got criticisms on the current approach but NO recommendation on how to actually do it right.
    It is not criticisms, just such approach will not work. Be sure, if it would possible we would say that ok here is the example

    With UI caching, i was able to bring it down to 12 seconds.
    Can you demonstrate the example which takes 82 sec and example with your caching and 12 sec?
  10. #30
    Quote Originally Posted by Vladimir View Post
    It is not criticisms, just such approach will not work. Be sure, if it would possible we would say that ok here is the example
    Can you demonstrate the example which takes 82 sec and example with your caching and 12 sec?
    Hi Vladimir,

    You are wrong in saying that it will not work as it actually worked. I agree with you that it might not be a good practice but i have no other option.

    The code that takes 82 seconds is similar to the code i posted at 10:30 AM. The one where you can see //ALREADY CACHED. I intentionally created a repetition of that phrase in hopes that someone will make an impression that it's already cached. I guessed I was wrong.

    These lines of codes doesn't work and I am not sure what your response about it, as I have tried to bring this to your attention for a couple of times now but you kept ignoring it and instead you kept pointing out that i need to cache the database objects when i have already put //ALREADY CACHED so many times.

    GridPanel gridPanel = new GridPanel();
    string gridConfig = string.Empty;
     
    //configure grid panel here
    gridPanel.Height = Unit.Pixel(500);
     
    //.... some more configuration from the database;
      
     gridConfig = gridPanel.ToConfig();
      
    gridPanel = new GridPanel(GridPanel.Config.ToConfig<GridPanel.Config>(gridConfig));
    ViewPort.Items.Add(gridPanel);
    Thanks for your time.
Page 3 of 4 FirstFirst 1234 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