We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22244
    • 144 Posts
    I have an module CMP page with items that can be set on active or inactive by clicking the checkbox. This can be done while creating or in the overview page.

    The checkbox renders fine in the create modular window but in the overview it only renders as the value 1 or 0.
    When I update an item it renders as a checkbox and when I’m finished updating it renders as the value true...

    This is the code used to display the checkbox.
     {
                header: _('bcontrol.active')
                ,dataIndex: 'active'
                ,sortable: false
                ,width: 30
                ,editor: { xtype: 'checkbox' }
            }
    


    What to do to show the checkbox in the correct way?
    Where can I find examples or documentation on this?

    Thank you so much for the reply!!
      • 28215
      • 4,149 Posts
      You’ll need to use: Ext.ux.grid.CheckColumn

      Check out manager/assets/modext/widgets/element/modx.grid.template.tv.js for a demo (the Template -> TVs tab).
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 22244
        • 144 Posts
        Wow.. that’s quick! Thanks for the great support Splittingred!
          • 22244
          • 144 Posts
          This totally rocks smiley It works like a charm.
            • 22244
            • 144 Posts
            One last thing, it seems that autosave doesn’t work for the checkbox when it’s displayed in the grid.
            The autosave only works for the other fields but not the checkbox. Is there a way to accomplish this.. I have looked for an example in modx where I see this functionality but I never see it with checkboxes. Is that correct or am I missing something?


                var tt = new Ext.ux.grid.CheckColumn({
                    header: _('bcontrol.active')
                    ,dataIndex: 'active'
                    ,width: 30
                    ,sortable: false
                });
                
                Ext.applyIf(config,{
                    id: 'bcontrol-grid-brands'
                    ,url: Bcontrol.config.connector_url
                    ,baseParams: { action: 'mgr/brand/getList' }
                    ,save_action: 'mgr/brand/updateFromGrid'
                    ,fields: ['id','brandid','name','active','extra','menu']
                    ,paging: true
                    ,autosave: true
            
              • 22244
              • 144 Posts
              In modx.grid.plugin.event.js I found:

                  var ec = new Ext.ux.grid.CheckColumn({
                      header: _('enabled')
                      ,dataIndex: 'enabled'
                      ,editable: true
                      ,width: 80
                      ,sortable: false
                  });


              I tried applying "editable: false" on the checkbox so the users can only edit it when the update the whole "table row" and not from the overview since I’m unable to autosave the checkbox in the grid.
              But I don’t see any effect using "editable: false" I can still select the object and change it in the grid. (no autosave afterwards).
                • 22244
                • 144 Posts
                Ok, I found some useful information in this topic about the autosave questions: http://modxcms.com/forums/index.php?topic=61410.0
                  • 33968
                  • 863 Posts
                  I'm trying to implement the same thing now. The example above is used with a local store and (I guess as you found out) it's not used with autosave.

                  Did you end up figuring this one out?