Results 1 to 7 of 7

Thread: Destroy Grid

  1. #1

    Default Answered: Destroy Grid

    Hello, I have an issue when upgrading to ExtJS 6.2.0:

    I have onExitClick method in my controller grid class:

    Code:
    onExitClick: function(btn, e) {
        this.getView().destroy();
    }
    But, after upgrading, when I call onExitClick method, I have an error:
    ext-all-rtl-debug.js:53308 Uncaught TypeError: Cannot read property 'destroy' of undefined()

    What is undefined is the binding. Before I call the method, grid.getBind() return an object with my store binded. But after this error, my grid is not destroyed, and grid.getBind() return undefined, and console throw the error above. If I call the method again, my grid is destroyed whithout errors.

    Can you help me?
    Thanks
    Albanir Neves

  2. Quote Originally Posted by StuartAshworth View Post
    Try adding a handler to the view's destroy method with a debugger statement in it. It sounds like the view is being destroyed automatically since the upgrade - that might help to figure out where the destroy is originating from.
    Thanks for this idea. I debugged ext codes and figure out the error.

    In grid's toolbar there's a field:
    Code:
    {
        xtype: 'textfield',
        flex: 1,
        reference: 'user',
        fieldLabel: 'User',
        bind: {
            value: '{usuarioSearched}',
            readOnly: !Ext.$('app-main')[0].getViewModel().get('permissoes.userAdmin'),
            fieldStyle: '{userFieldStyle}'
        }
    }

    Note readOnly property in bind. In 6.0.2 version it works but it doesn't in 6.2.0. Ok, it's a bad pratice. Now I did the following:
    Code:
    {
        xtype: 'textfield',
        flex: 1,
        reference: 'user',
        fieldLabel: 'User',
        bind: {
            value: '{usuarioSearched}',
            readOnly: '{userNotAdmin}',
            fieldStyle: '{userFieldStyle}'
        }
    }
    And in viewModel I added the formula:

    Code:
    userNotAdmin: function(get){
        return !Ext.$('app-main')[0].getViewModel().get('permissoes.userAdmin');
    }
    Is someone front this issue, maybe it can help.

  3. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    Thanks for the report. Can you please post a test case which reproduces this issue?
    https://fiddle.sencha.com/#home

  4. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    913
    Answers
    105

    Default

    It seems to work fine for me. Here is a simple fiddle to test. No errors. Is this what you are doing or I misunderstood your problem?

  5. #4

    Default

    Quote Originally Posted by hakimio View Post
    It seems to work fine for me. Here is a simple fiddle to test. No errors. Is this what you are doing or I misunderstood your problem?
    Yes, this is what i'm trying to do. But in my big app it throws a error. I'll test more times. If I get a solution, I post here.

    Thanks by now.
    Thanks
    Albanir Neves

  6. #5
    Sencha Premium User StuartAshworth's Avatar
    Join Date
    Feb 2009
    Location
    Glasgow, Scotland
    Posts
    418
    Answers
    17

    Default

    Try adding a handler to the view's destroy method with a debugger statement in it. It sounds like the view is being destroyed automatically since the upgrade - that might help to figure out where the destroy is originating from.
    SenchaTalk.com - a free Slack community for all things Sencha. Join Now!

    Learn Ext JS 6 with my new ebook - Ext JS 6: Getting Started. Get a Sample Chapter now!

    Need help with Sencha development, code reviews or training? Get in touch!

    [email protected]
    @StuartAshworth9

  7. #6

    Default

    Quote Originally Posted by StuartAshworth View Post
    Try adding a handler to the view's destroy method with a debugger statement in it. It sounds like the view is being destroyed automatically since the upgrade - that might help to figure out where the destroy is originating from.
    Thanks for this idea. I debugged ext codes and figure out the error.

    In grid's toolbar there's a field:
    Code:
    {
        xtype: 'textfield',
        flex: 1,
        reference: 'user',
        fieldLabel: 'User',
        bind: {
            value: '{usuarioSearched}',
            readOnly: !Ext.$('app-main')[0].getViewModel().get('permissoes.userAdmin'),
            fieldStyle: '{userFieldStyle}'
        }
    }

    Note readOnly property in bind. In 6.0.2 version it works but it doesn't in 6.2.0. Ok, it's a bad pratice. Now I did the following:
    Code:
    {
        xtype: 'textfield',
        flex: 1,
        reference: 'user',
        fieldLabel: 'User',
        bind: {
            value: '{usuarioSearched}',
            readOnly: '{userNotAdmin}',
            fieldStyle: '{userFieldStyle}'
        }
    }
    And in viewModel I added the formula:

    Code:
    userNotAdmin: function(get){
        return !Ext.$('app-main')[0].getViewModel().get('permissoes.userAdmin');
    }
    Is someone front this issue, maybe it can help.
    Thanks
    Albanir Neves

  8. #7
    Sencha Premium User StuartAshworth's Avatar
    Join Date
    Feb 2009
    Location
    Glasgow, Scotland
    Posts
    418
    Answers
    17

    Default

    Nice one, glad you got it sorted!
    SenchaTalk.com - a free Slack community for all things Sencha. Join Now!

    Learn Ext JS 6 with my new ebook - Ext JS 6: Getting Started. Get a Sample Chapter now!

    Need help with Sencha development, code reviews or training? Get in touch!

    [email protected]
    @StuartAshworth9

Similar Threads

  1. Replies: 2
    Last Post: 16 Oct 2014, 7:46 AM
  2. Replies: 5
    Last Post: 20 Aug 2012, 12:32 AM
  3. Replies: 5
    Last Post: 18 Nov 2008, 1:23 AM
  4. [Ext.BasicDialog].destroy(true) doesn't destroy shadow
    By diegovilar in forum Ext 1.x: Bugs
    Replies: 1
    Last Post: 25 Mar 2007, 12:42 PM

Posting Permissions

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