Results 1 to 7 of 7

Thread: Unclosed DIV in CheckBoxDefaultAppearance.render

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTGWT-3293 in 3.0.7.
  1. #1
    Sencha Premium Member
    Join Date
    Sep 2013
    Posts
    4

    Default Unclosed DIV in CheckBoxDefaultAppearance.render

    Hi,

    I want to understand the reason why wrapper div is opened in CheckBoxDefaultAppearance.render but isn't closed:
    PHP Code:
      @Override
      
    public void render(SafeHtmlBuilder sbBoolean valueCheckBoxCellOptions options) {
        
    String checkBoxId XDOM.getUniqueId();


        
    String nameParam options.getName() != null " name='" options.getName() + "' " "";
        
    String disabledParam options.isDisabled() ? " disabled=true" "";
        
    String readOnlyParam options.isReadonly() ? " readonly" "";
        
    String idParam " id=" checkBoxId;
        
    String typeParam " type=" type;
        
    String checkedParam value " checked" "";


        
    sb.appendHtmlConstant("<div class=" style.wrap() + ">");
        
    sb.appendHtmlConstant("<input " typeParam nameParam disabledParam readOnlyParam idParam checkedParam " />");
        
    sb.appendHtmlConstant("<label for=" checkBoxId " class=" style.checkBoxLabel() + ">");
        if (
    options.getBoxLabel() != null) {
          
    sb.appendHtmlConstant(options.getBoxLabel());
        }
        
    sb.appendHtmlConstant("</label>");


      } 
    Because this produces issues for using CheckBoxCell in ListView, I would like to understand will this be fixed in next version or this isn't a bug?

  2. #2
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976

    Default

    Thanks for the report. This looks to be a bug. I moved it to the proper forums and pushed it into the tracking system

  3. #3
    Sencha User
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737

    Default

    I've filed this internally so we can fix it, but can you clarify as to how it is causing problems in the listview? As far as I can tell, the reason that this hasn't caused problems so far is that the browser automatically closes the div when a parent tag is closed (each cell rendered in a parent is usually isolated in a parent tag, whether in ListView, Grid, or even CompositeCell), so you seem to be rendering two cells back to back?

  4. #4
    Sencha Premium Member
    Join Date
    Sep 2013
    Posts
    4

    Default

    Thanks for the answers.

    I need something similar to CheckBoxListView from GXT 2: http://www.sencha.com/examples-2/#checkboxlistview

    And I was able to produce it by extending CheckBoxCell for my ListView. Here is my code:

    Code:
    public class Gxt3Sandbox implements EntryPoint {
    
    
        @Override
        public void onModuleLoad() {
            ExampleModelProperties properties = GWT.create(ExampleModelProperties.class);
            ListStore<ExampleModel> store = new ListStore<ExampleModel>(properties.id());
            store.add(new ExampleModel(1, "test 1", false));
            store.add(new ExampleModel(2, "test 2", true));
            store.add(new ExampleModel(3, "test 3", true));
            store.add(new ExampleModel(4, "test 4", false));
            store.setAutoCommit(true);
    
    
            ListView<ExampleModel, Boolean> listView = new ListView<ExampleModel, Boolean>(
                    store, properties.checked(), new LabeledCheckBoxCell(store, properties.name())
            );
            RootPanel.get().add(listView);
        }
    
    
        public static class LabeledCheckBoxCell extends CheckBoxCell {
    
    
            private final Store store;
            private final ValueProvider label;
            private Object key = null;
    
    
            public LabeledCheckBoxCell(Store store, ValueProvider valueProvider) {
                this.store = store;
                this.label = store.wrapRecordValueProvider(valueProvider);
            }
    
    
            @Override
            public String getBoxLabel() {
                if (key == null) {
                    return "";
                }
                Object model = store.findModelWithKey(key.toString());
                return label.getValue(model).toString();
            }
    
    
            @Override
            public void render(Context context, Boolean value, SafeHtmlBuilder sb) {
                key = context.getKey();
                try {
                    super.render(context, value, sb);
                } finally {
                    key = null;
                }
            }
        }
    
    
        public static class ExampleModel {
            private long id;
    
    
            private String name;
    
    
            private boolean checked;
    
    
            public ExampleModel(long id, String name, boolean checked) {
                this.id = id;
                this.name = name;
                this.checked = checked;
            }
    
    
            public long getId() {
                return id;
            }
    
    
            public void setId(long id) {
                this.id = id;
            }
    
    
            public String getName() {
                return name;
            }
    
    
            public void setName(String name) {
                this.name = name;
            }
    
    
            public boolean isChecked() {
                return checked;
            }
    
    
            public void setChecked(boolean checked) {
                this.checked = checked;
            }
        }
    
    
        public static interface ExampleModelProperties extends PropertyAccess<ExampleModel> {
            ModelKeyProvider<ExampleModel> id();
            ValueProvider<ExampleModel, String> name();
            ValueProvider<ExampleModel, Boolean> checked();
        }
    }
    But because of unclosed DIV I see "tree of checkboxes" in the ListView (1.png) and when I replace CheckBoxAppearance with implementation that closes this DIV everything works as expected (2.png):
    Code:
    public class CheckBoxAppearance extends CheckBoxDefaultAppearance {
    
    
        @Override
        public void render(SafeHtmlBuilder sb, Boolean value, CheckBoxCell.CheckBoxCellOptions options) {
            super.render(sb, value, options);
            sb.appendHtmlConstant("</div>");
        }
    }
    Attached Images Attached Images
    • File Type: png 1.PNG (2.4 KB, 21 views)
    • File Type: png 2.PNG (2.5 KB, 21 views)

  5. #5
    Sencha User
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737

    Default

    Thanks for sharing, with your permission we'll adapt something like this for our docs as a future sample.

    I've fixed this issue, and it is currently awaiting review.

  6. #6
    Sencha Premium Member
    Join Date
    Sep 2013
    Posts
    4

    Default

    Thanks, Colin

    Sure, feel free to use it as you want

  7. #7
    Sencha Sr Product Manager
    Join Date
    Jan 2012
    Location
    Arlington, WA
    Posts
    1,167

    Default

    Just an update, GXT 3.0.7 has been released with this issue fixed in it.

    It can be downloaded:
    https://support.sencha.com/index.php#dash
    or
    http://docs.sencha.com/gxt/3.1/getti...ven/Maven.html

Posting Permissions

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