[CLOSED] Dynamic and static data in Store

  1. #1

    [CLOSED] Dynamic and static data in Store

    I add static data to the store:

    List<object> data = new List<object>() {
                        new { name="", grouptype="Normal Types", fieldtype="SimpleText", tooltip="", icon="../Images/buttons/01_simpletext.svg" },
                    new { name="", grouptype="Normal Types", fieldtype="LongText", tooltip="", icon="../Images/buttons/02_textlong.svg"  },
                    new { name="", grouptype="Normal Types", fieldtype="Numeric", tooltip="", icon="../Images/buttons/03_numeric.svg"  }
    };
        
                        LabDatatoStore();
        
                        this.StoreControlTypes.DataSource = data;
                        this.StoreControlTypes.DataBind();
    and I am calling LabDatatoStore() to add also some dynamic data from the database:

        protected void LabDatatoStore()
                {
                    DAL.DataContext dc = new DAL.DataContext();
        
                    var data = from i in dc.Tests
                               where i.id != "HEIGHT" && i.id != "WEIGHT"
                               select new { fieldtype = i.id, grouptype = "Data Types", tooltip = i.Name, icon = "../Images/test.png" };
        
                    this.StoreControlTypes.DataSource = data;
                    this.StoreControlTypes.DataBind();
                }
    But I get only the static data. How I can get both ones?
    Last edited by fabricio.murta; Apr 26, 2017 at 4:40 PM.
  2. #2
    Hello @atroul!

    You are replacing the "dynamic data" from LabDatatoStore() with the static data. You should merge the two data lists and only perform data binding with the full data.

    In other words, instead, you can just:

    List<object> data = new List<object>() {
                        new { name="", grouptype="Normal Types", fieldtype="SimpleText", tooltip="", icon="../Images/buttons/01_simpletext.svg" },
                        new { name="", grouptype="Normal Types", fieldtype="LongText", tooltip="", icon="../Images/buttons/02_textlong.svg"  },
                        new { name="", grouptype="Normal Types", fieldtype="Numeric", tooltip="", icon="../Images/buttons/03_numeric.svg"  }
    };
        
    data.AddRange(LabDatatoStore()); // untested, just merge the two lists!
        
    this.StoreControlTypes.DataSource = data;
    this.StoreControlTypes.DataBind();
    protected void LabDatatoStore()
    {
        DAL.DataContext dc = new DAL.DataContext();
    
        var data = from i in dc.Tests
            where i.id != "HEIGHT" && i.id != "WEIGHT"
            select new { fieldtype = i.id, grouptype = "Data Types", tooltip = i.Name, icon = "../Images/test.png" };
    
        return data;
    }
    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello Fabricio, thank you! It solved my problem, you can close the thread. I just changed it a bit because there were some errors. Here is how I fixed it:
    List<object> data = new List<object>() {
                        new { name="", grouptype="Normal Types", fieldtype="SimpleText", tooltip="", icon="../Images/buttons/01_simpletext.svg" },
                        new { name="", grouptype="Normal Types", fieldtype="LongText", tooltip="", icon="../Images/buttons/02_textlong.svg"  },
                        new { name="", grouptype="Normal Types", fieldtype="Numeric", tooltip="", icon="../Images/buttons/03_numeric.svg"  }
    };
    
    DAL.DataContext dc = new DAL.DataContext();
    
        var dataDyn = from i in dc.Tests
            where i.id != "HEIGHT" && i.id != "WEIGHT"
            select new { fieldtype = i.id, grouptype = "Data Types", tooltip = i.Name, icon = "../Images/test.png" };
    
        
    data.AddRange(dataDyn.ToArray()); 
        
    this.StoreControlTypes.DataSource = data;
    this.StoreControlTypes.DataBind();
  4. #4
    Hello! Glad it helped you solve the issue!

    Without being able to actually run some code it is hard to provide something that works "out of the box". But I'm glad the idea was right in your case. Thanks for sharing the outcome!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 3
    Last Post: Aug 03, 2015, 4:59 PM
  2. Store Data is not displaying in Dynamic Gridpanel
    By rendongsc in forum 1.x Help
    Replies: 1
    Last Post: Apr 11, 2012, 9:19 PM
  3. Store Data is not displaying in Dynamic Gridpanel
    By NishaLijo in forum 1.x Help
    Replies: 1
    Last Post: Apr 11, 2012, 9:18 PM
  4. Replies: 1
    Last Post: Mar 08, 2012, 2:52 PM
  5. Replies: 10
    Last Post: Nov 20, 2008, 3:17 PM

Posting Permissions