[CLOSED] Cloning components and stores

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Cloning components and stores

    Is there any way to clone a component or store?

    I found something on the web like Ext.net.clone but it didn't exist for me.
    Last edited by Daniil; Jun 12, 2012 at 4:23 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Ext.net.clone is for cloning simple variables including array, {}-like objects without keeping the old reference.

    There is an ExtJS analog with extended functionality to also clone DOM nodes and Date.
    http://docs.sencha.com/ext-js/4-1/#!...t-method-clone

    I will consider with my colleagues we do still need our own Ext.net.clone method or not.

    Regarding your issue with cloning components. Please use the cloneConfig method to clone Ext.Components.
    http://docs.sencha.com/ext-js/4-1/#!...od-cloneConfig

    Store is not an inheritor of Ext.Component, so, there is no cloneConfig method.

    But I am not sure you need two same Stores. You could attach a single Store to any amount of bindable components.

    Please clarify why do you need to clone it?
  3. #3
    Please avoid cloning of components, UI control is complex object and cannot be clonned correctly in all cases.
    It much better to create method which creates required widget. If you know that a type of widget can be used in several places then create method to create and return the widget. It is more safely.

    Another option, implement custom control, after that you will be able to create widgets of the same type
  4. #4
    Quote Originally Posted by Daniil View Post
    But I am not sure you need two same Stores. You could attach a single Store to any amount of bindable components.

    Please clarify why do you need to clone it?
    I wanted to create multiple instances of a store as I'm not sure how to share the same store across multiple data grids and then filter each grid to show a different part of the store's data.
  5. #5
    I basically want 4 identical grids sharing the same store but with different filters.

    I was hoping I could use the <ext:GridPanel> tag to create a grid wrapped in a container. Then when loading the page (Page_Load function), I could copy the grid and dynamically created 3 other grids with the same store but with different filters and add them to the container. It seemed trivial at first, but I ended up hitting a bunch of road blocks.
  6. #6
    Yes, if you need different filtering, you need different stores.

    I was hoping I could use the <ext:GridPanel> tag to create a grid wrapped in a container. Then when loading the page (Page_Load function), I could copy the grid and dynamically created 3 other grids with the same store but with different filters and add them to the container. It seemed trivial at first, but I ended up hitting a bunch of road blocks.
    The following thread could, probably, help to copy/clone a control.
    http://forums.asp.net/t/617980.aspx

    Though I would also prefer, as Vladimir suggested, to create a code behind method which would create and return a GridPanel (with Store) instance. Then you could easily create as many same GridPanel instances (just changing IDs) as you wish.

    Implementing a custom server control inherited from GridPanel would be even better in the design aspect.
  7. #7
    Yeah, I've changed my approach to write code to create the grid panel from scratch in c#.

    What's the solution for cloning the data from a store? Could I add a custom row filter and filter the grid's rows and not the actual store?
  8. #8
    Quote Originally Posted by craig2005 View Post
    What's the solution for cloning the data from a store?
    Well, you should set up the same object to Stores DataSource.

    Quote Originally Posted by craig2005 View Post
    Could I add a custom row filter and filter the grid's rows and not the actual store?
    No, filtering (and any other data layer operations like loading, sorting, grouping) is performed on Store level.
  9. #9
    Can I bind multiple stores to a single datasource? Would that be the way to go?
  10. #10
    Am i missing something?

    store.Listeners.Load.Fn = "populateSolrStores('" + id + "')";
    When you use a Handler the code works fine. When you use Fn, it immediately tries to execute the code in the function. This was driving me nuts and I thought the load event was broken until i tried calling this function through the "Handler" method instead.
Page 1 of 2 12 LastLast

Similar Threads

  1. Combobox with two stores
    By SMS in forum 1.x Help
    Replies: 3
    Last Post: Jul 12, 2011, 11:45 AM
  2. [CLOSED] Stores and ComboBoxes
    By state in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 05, 2009, 3:07 PM
  3. [CLOSED] ComboBox Stores
    By state in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 20, 2009, 2:43 PM
  4. [CLOSED] Moving between 2 stores
    By CMA in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Aug 17, 2009, 10:55 AM
  5. [CLOSED] Committing several stores
    By pschojer in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 17, 2009, 8:32 AM

Posting Permissions