[OPEN] [#1629] [4.7.1] Checkbox + setVisible error

  1. #1

    [OPEN] [#1629] [4.7.1] Checkbox + setVisible error

    Hello
    I have a checkbox that has not been rendered and I need to set setVisible on it
    it's failing for me

    note that calling setVisible(false) works fine

    <%@ Page Language="C#" %>
    
    <script>
    	function showWindow() {
    		var config = {
    			title: '',
    			width: 800,
    			height: 400,
    			collapsible: false,
    			modal: true,
    			items: [
    				{
    					xtype: "checkbox",
    					boxLabel: 'Checkbox',
    					itemId:'cbo'
    				}
    			]
    		};
    
    
    		var win = new Ext.Window(config);
    
    		var cbo = win.down('#cbo');
    		
    		// not renered, fails with true, works with false
    		cbo.setVisible(true);
    
    		win.show();
    
    		
    
    	}
    </script>
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
    </head>
    <body>
    	
    	
        <form runat="server">
    	    <ext:ResourceManager ID="ResourceManager1" runat="server"  Theme="Gray" Namespace="" RethrowAjaxExceptions="true">
    	    </ext:ResourceManager>
            
    		<ext:Button runat="server" Text="Show window" OnClientClick="showWindow()" Height="30"></ext:Button>
        </form>
    </body>
    </html>

    Additional question
    on code above, when I call win.setVisible it goies into this method
    Ext.define("gh1550", {
        override: "Ext.Component",
        hide: function () {
            var me = this,
                zim = me.zIndexManager,
                selectTopMostCmp = false,
                retVal;
    
            // Checks if the z-index manager is enabled and the on front compoent
            // is being hidden.
            if (Ext.isObject(zim) && me == zim.front && Ext.isObject(zim.topMost)) {
                selectTopMostCmp = true;
            }
    or this method (depends if hide/show method is called)

    Ext.define("gh1567", {
        override: "Ext.form.field.Checkbox",
        show: function (animateTarget, callback, scope) {
            var me = this,
                retVal = me.callParent(arguments);
    
            me.innerWrapEl.setStyle('display', undefined);
            return retVal;
        }
    });
    where it fails on me.innerWrapEl (as it was not rendered)


    what are those gh1567 and gh1550 overrides ?
    Last edited by jirihost; Feb 20, 2019 at 11:44 AM.
  2. #2
    Hello @jirihost!

    The ghNNNN overrides refers to the respective github issue they fix. So just replace the NNNN in the url: https://github.com/extnet/Ext.NET/issues/NNNN to see what issue it did address.

    You cannot set visible/show/hide what's not rendered. I believe what you need to change is just the 'hidden' config of the component before you have it rendered. After it is rendered, then you can call those methods. It is not reliable (can't find references to it in the official documentation) but you can check if the component's rendered is set as true to determine whether it is rendered or not. I believe it would be safer to just let the window render (but instantiate it as 'hidden' so it is not actually drawn to screen) then do the changes you need before showing it.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Ok
    thanks for answer

    Isn't that strange that I can call "show" method but "hide" method fails?
    I understand that on config object I can't call any method, but once I have instance of object, is there a reason why I can't simply call any method (and for example in this case, if object is not rendered yet, it just sets its config accordingly (so when rendered it's rendered hidden/visible?

    I was under impression it works like that with most of methods

    Thanks for any additional explanation
  4. #4
    Hello @jirihost!

    Yes, you're right, after all, in general, the methods should handle it when they are called to rendered and not rendered elements, and the overrides should just skip what they would try to do whenever the component is not rendered.

    We've logged issue #1629 to track this defect and we'll post a note here as soon as we get it fixed!
    Fabrício Murta
    Developer & Support Expert
  5. #5
    We also faced the problem with the visibility of checkboxes. Our workaround is to wrap them in a Panel and show/hide the panel instead of the checkbox itself.

    Any news about a fix for that?
  6. #6
    Hello @anwichmann!

    As long as you have the checkboxes rendered when you call the visibility methods (show/hide), you shouldn't have issues with it. If you do, maybe it is not the same issue as the one logged here.

    Assuming you are using a recent Ext.NET version, at least. To avoid the issue in question here, you can just switch the properties of the components instead of calling the setters, which should be a valid change until the component is rendered (then the setters should work fine).

    We had some other issues with actually showing/hiding checkboxes but as far as the ones reported, they were fixed. To name a couple: #1569 (fix available since Ext.NET 4.5.1) and #1567 (4.6.0).

    If your issue is related to one of those above, you may be running an old version of Ext.NET.

    If your issue is not related to non-rendered components and you're on a newer Ext.NET release, I'd say you may have a case we are not aware of and opening a thread to handle that would be very welcome.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 3
    Last Post: Oct 09, 2018, 4:36 AM
  2. Replies: 1
    Last Post: Sep 10, 2018, 4:26 PM
  3. Replies: 3
    Last Post: May 29, 2013, 3:49 AM
  4. Replies: 10
    Last Post: Apr 25, 2013, 5:38 AM
  5. [CLOSED] Open window from checkbox
    By Adrian in forum 1.x Help
    Replies: 2
    Last Post: Aug 26, 2008, 7:48 PM

Posting Permissions