We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25551 ☆ A M B ☆
    • 1,231 Posts
    Hello, I am trying to figure out how to hide an option that is generated with extjs but only if a value is equal to 0.

    an example of what I am trying to do but errors. Obviously it’s not right but if someone knows how to or if you can do if statements like that to help?

    
    ,fields: [{
                xtype: 'statictextfield'
                ,name: 'id'
                ,fieldLabel: _('id')
                ,submitValue: true
            }
    if(artwork != 0){
    ,{
                xtype: 'checkbox'
                ,fieldLabel: 'artwork'
                ,name: 'artwork'
                ,description: ''
                ,id: 'show-artwork'
                ,checked: true 
                ,inputValue: 1
            }
    }
    ]
    
      Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
      AugmentBLU - MODX Partner

      BLUcart - MODX Revolution E-Commerce & Shopping Cart
      • 28215
      • 4,149 Posts
      ,{
                  xtype: 'checkbox'
                  ,fieldLabel: 'artwork'
                  ,name: 'artwork'
                  ,description: ''
                  ,id: 'show-artwork'
                  ,checked: true 
                  ,inputValue: 1
                  ,hidden: artwork != 0 ? false : true
      }
      
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 25551 ☆ A M B ☆
        • 1,231 Posts
        Thanks Shaun,

        I tried that and it’s saying that artwork is not defined. I’m not entirely sure how to pass data through extjs but hopefully the more questions that get answered the quicker I learn and the less I ask in future lol.

        Anyway here’s the code in cut down version... it’s your gallery snippet again. I know I have to define the artwork variable but I’m unsure how to get the value from the fields.

        GAL.view.AlbumItems = function(config) {
            config = config || {};
            
            this._initTemplates();
            Ext.applyIf(config,{
                url: GAL.config.connector_url
                ,fields: ['id','album','name','description','mediatype','createdon','createdby','filename','filesize','thumbnail','image','image_width','image_height','tags','active','artwork','rank','absoluteImage','relativeImage','menu']
        
        // lots of code deleted here to keep the post small
        
        GAL.window.UpdateItem = function(config) {
        
        var artwork = config.fields+'artwork'; // This doesn't work, it was my attempt at trying to figure out how to get the data.  if I set the var artwork = 0 it does what I want but I want that to be taken dependant on the image that is clicked.
        
            config = config || {};
            this.ident = config.ident || 'gupdit'+Ext.id();
            Ext.applyIf(config,{
                title: _('gallery.item_update')
                ,id: this.ident
                ,height: 150
                ,width: 475
                ,url: GAL.config.connector_url
                ,action: 'mgr/item/update'
                ,fileUpload: true
                ,fields: [{
                    xtype: 'statictextfield'
                    ,name: 'id'
                    ,fieldLabel: _('id')
                    ,submitValue: true
                },{
                    xtype: 'checkbox'
                    ,fieldLabel: 'artwork'
                    ,name: 'artwork'
                    ,description: ''
                    ,id: 'artwork'
                    ,checked: true 
                    ,inputValue: 1
                    ,hidden: artwork != 0 ? false : true
                }
        	
        		]
            });
            GAL.window.UpdateItem.superclass.constructor.call(this,config);
        };
        Ext.extend(GAL.window.UpdateItem,MODx.Window);
        Ext.reg('gal-window-item-update',GAL.window.UpdateItem);
        
          Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
          AugmentBLU - MODX Partner

          BLUcart - MODX Revolution E-Commerce & Shopping Cart
          • 25551 ☆ A M B ☆
          • 1,231 Posts
          Still a little lost on this one if someone is able to help?

          Thanks!
            Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
            AugmentBLU - MODX Partner

            BLUcart - MODX Revolution E-Commerce & Shopping Cart
            • 11076
            • 159 Posts
            Any breakthrough yet? if so, can you please share? tongue

            I’m curious in how to show certain TV in case Another-TV is Set, and hide it otherwise?
              Michael Shraibman( gOmp)  | Freelance Design & Development | wink  impossible is nothing...