[CLOSED] Caching Dynamic Grids

Page 4 of 4 FirstFirst ... 234
  1. #31
    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.
    Here is my test case. In that case, I create 6 grids with 40 columns in each grid

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>TreeGrid - Ext.NET Examples</title>   
    
    
        <script runat="server">
            public class Entity
            {
                public string DataType
                {
                    get;
                    set;
                }
    
    
                public string Label
                {
                    get;
                    set;
                }
    
    
                public string Format
                {
                    get;
                    set;
                }
    
    
                public string Title
                {
                    get;
                    set;
                }
    
    
                public int Width
                {
                    get;
                    set;
                }
    
    
                public string DataColumn
                {
                    get;
                    set;
                }
    
    
                public bool Editable
                {
                    get;
                    set;
                }
            }
    
    
            protected void Page_Load(object sender, EventArgs e)
            {
                List<Entity> columns = new List<Entity>();
    
    
                for (int i = 0; i < 40; i++)
                {
                    Entity entity = new Entity 
                    { 
                        DataType = "text",
                        Title = "Column" + i,
                        Width = 100,
                        DataColumn = "Column" + i,
                        Editable = true
                    };
    
    
                    columns.Add(entity);
                }
    
    
                Application["TESTCOLUMNS"] = columns;
    
    
                System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                watch.Start();
                for (int i = 0; i < 6; i++)
                {
                    this.RenderGridMe();
                }
                watch.Stop();
    
    
                X.Js.Alert(watch.ElapsedMilliseconds.ToString());
                
            }
    
    
            private void RenderGridMe()
            {
                //THIS IS CACHED ALREADY. THIS IS CACHED ALREADY. THIS IS CACHED ALREADY. THIS IS CACHED ALREADY
                List<Entity> columns = Application["TESTCOLUMNS"] as List<Entity>;
    
    
                GridPanel gridPanel = new GridPanel();
                Store store = new Store();            
    
    
                //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.
                {
                    store.Fields.Add(column.DataColumn);
                    
                    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
    
    
                gridPanel.Store.Add(store);
                Viewport1.Items.Add(gridPanel);
            }
    
    
            private Column CreateNumberColumn(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 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;
            }
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Viewport ID="Viewport1" runat="server">
            </ext:Viewport>
        </form>
    </body>
    </html>
    Grids creating takes apprx. 4-6 ms on my computer. So, 82 sec is just unreal number for me.

    You are wrong in saying that it will not work as it actually worked.
    Do you mean controls caching is working for you? Can you demonstrate it?

    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.
    As I mentioned before, if config creates other controls (like columns, store and etc) then it cannot be deserialized because render process has no reverse
  2. #32
    Quote Originally Posted by Vladimir View Post

    Do you mean controls caching is working for you? Can you demonstrate it?
    As I mentioned before, if config creates other controls (like columns, store and etc) then it cannot be deserialized because render process has no reverse
    public partial class Cloning : System.Web.UI.Page
       {
    
            protected void Page_Load(object sender, EventArgs e)
            {
                string gridKey = "MYGRID";
    
                if (Application[gridKey] == null)
                {
                    GridPanel myGridPanel = new GridPanel();
    
                    for (int i = 0; i < 10; i++)
                    {
                        Column column = new Column();
                        column.Text = "Column" + i.ToString();
                        column.Width = Unit.Pixel(100);
    
                        myGridPanel.ColumnModel.Columns.Add(column);
                    }
    
                    Application[gridKey] = myGridPanel;
                }
    
    
                GridPanel gridPanel = Application[gridKey] as GridPanel;
                GridPanel clone = gridPanel.Clone();
    
                Viewport1.Items.Add(clone);
            }
        }
    
        public static class Extension
        {
    
            public static GridPanel Clone(this GridPanel grid)
            {
                GridPanel newPanel = new GridPanel();
    
                foreach (Column column in grid.ColumnModel.Columns)
                    newPanel.ColumnModel.Columns.Add(column.Clone());
    
                return newPanel;
            }
    
            public static Column Clone(this Column column)
            {
                Column newColumn = new Column();
    
                newColumn.ID = Guid.NewGuid().ToString();
                newColumn.Text = column.Text;
                newColumn.Width = column.Width;
    
                return newColumn;
            }
    
        }
    I am sorry I can not give you the full code everytime because I am under NDA. But this one should work. I generate the grid the first time, cache it on the application level and clone it whenever i need it. I initially implement this using ICloneable through the Clone method (read the previous thread as I have mentioned this before). I can not give that code to you as it exposes some proprietary information. I cut and paste here some relevant code so you can see that it is actually working.

    I agree with your time results. However, there basis of the test results you have provided are meaningless, very basic columns, I am configuring drop down columns applying different logic, some extracting options from real time data by the hour. The grid i am working on is a stock trading grid. There are lots of computation and long process of configuring it. What i was asking was a way to cache it.

    Your reply, on the other hand, for the most part, is to challenge the validity of the business requirement. And you have provided me concepts that are flawed. The code above proves that controls can be cached and reused. On generic principle, it might be a bad practice. But that is the main reason why I went to this forum to seek alternatives, but you and your team offered no alternative, except to discredit the fact that my issue is valid.

    So here is the code. It is working.
    Last edited by alanflores; Aug 21, 2013 at 6:58 PM.
  3. #33
    I am sorry I can not give you the full code everytime because I am under NDA. But this one should work. I generate the grid the first time, cache it on the application level and clone it whenever i need it.
    So, you do what we told you in previous posts. You recreate (clone) grid and columns for each request, you don't use one instance only
    So, what a sense to cache controls instead business objects with required properties like we told you previously?

    I agree with your time results. However, there basis of the test results you have provided are meaningless, very basic columns, I am configuring drop down columns applying different logic, some extracting options from real time data by the hour. The grid i am working on is a stock trading grid. There are lots of computation and long process of configuring it. What i was asking was a way to cache it.
    So, as you said the long process is not control creating. It is your code for extracting required data. Why you don't want to cache it instead controls? Besides you recreate (clone) controls each time, you don't reuse one instance only.

    The code above proves that controls can be cached and reused.
    No, it doesn't prove. You recreate controls. It just proves that control creating is not long process and should not be cached. You need to cache data extracting only because it is bottle neck. And we (I and @chau) told about it in this thread.
  4. #34
    Yeah. I spent enough time here already but I'm getting nowhere.
    Thanks for your time and all your very good suggestions.

    Oh. There was none.
Page 4 of 4 FirstFirst ... 234

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