Results 1 to 3 of 3

Thread: Extending views: unexpected runtime behaviour

  1. #1
    Sencha User
    Join Date
    Nov 2009
    Location
    Aveiro, Portugal
    Posts
    47
    Answers
    3

    Default Answered: Extending views: unexpected runtime behaviour

    I've created a simple base view (called SyncBase) with a grid, with its ViewModel and View Controller. Since my application can have anonymous and authenticated users, I want to reuse that view with or without buttons to change the grid contents.

    To do so, I created two new classes, based on SyncBase: SyncReadOnly and SyncReadWrite. SyncReadOnly does not add anything to the base view. SyncReadWrite adds a tbar to the grid.

    I've created a fiddle to show the classes and their instantiation.

    I have a card layout that display the desired grid: without the toolbar (the SyncReadOnly) or with the toolbar (SyncReadWrite).

    The example works perfect if and only if I instanciate the SyncReadOnly first. If I create the SyncReadWrite in first place, when I instanciate the SyncReadOnly afterwards, it also gets the toolbar!

    To confirm the good behaviour, click on the "Show Grid ReadOnly" in the first place. Afterwards, you can change the views without any problem. But if you click on the "Show Grid ReadWrite" in the first place, both grid will have the toolbar.

    I would like to understand this different behaviour. Does it make sense?

    Thanks in advance for reading such a long entry.

    P.S. I could use a condition in the view initComponent to create the toolbar if the user is authenticated. But I'm trying to instantiate a different class if the user is authenticated or not.

  2. By apply-ing the new config to the items[], you are directly manipulating that property on the class, so any future instances of the class will inherit the changes you apply. You could add the toolbar to the grid instance once it's instantiated.

    Thanks
    Joel

  3. #2
    Sencha User
    Join Date
    Nov 2009
    Location
    Aveiro, Portugal
    Posts
    47
    Answers
    3

    Default

    I think this is related with https://www.sencha.com/forum/showthread.php?307700When I extend the base class and add a toolbar to the grid, I'm changing the base class grid. That's not what I would like to happen.

  4. #3
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    By apply-ing the new config to the items[], you are directly manipulating that property on the class, so any future instances of the class will inherit the changes you apply. You could add the toolbar to the grid instance once it's instantiated.

    Thanks
    Joel

Similar Threads

  1. Unexpected Image link behaviour
    By allisterf in forum Sencha Architect 2.x: Bugs
    Replies: 0
    Last Post: 16 Jun 2012, 5:03 AM
  2. Unexpected Image link behaviour
    By allisterf in forum Sencha Architect 2.x: Help & Discussions
    Replies: 0
    Last Post: 16 Jun 2012, 5:02 AM
  3. [2.1][FIXED] Unexpected MessageBox behaviour
    By rstuart in forum Ext 2.x: Bugs
    Replies: 6
    Last Post: 9 May 2008, 11:29 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •