Code Monkey home page Code Monkey logo

Comments (5)

HoochSDS avatar HoochSDS commented on June 29, 2024

Further studies, perhaps they are useful:

If the table is loaded in the background (not visible) the height of the tbody div is set to 0.

grafik

If the table is visible and you refresh the table the height of the tbody div is set correct.

grafik

It's hard to find where the tbody div is set in the GWT-Material code.

from gwt-material-table.

HoochSDS avatar HoochSDS commented on June 29, 2024

Workaround for the row override problem
You can extend the custom render with a setHeight statement

  public static class CustomCategoryComponent extends CategoryComponent {
    public CustomCategoryComponent(String category) {
      super(category);
    }

    @Override
    protected void render(TableSubHeader subheader) {
      super.render(subheader);

      subheader.setHeight("45px");    // Workaround 

      subheader.setOpenIcon(IconType.FOLDER_OPEN);
      subheader.setCloseIcon(IconType.FOLDER);
    }
  }

Maybe someone will help

from gwt-material-table.

BenDol avatar BenDol commented on June 29, 2024

Strange issue, could be a custom style issue in your project. Can you provide a small project to reproduce this?

from gwt-material-table.

HoochSDS avatar HoochSDS commented on June 29, 2024

Hi, no I don't think it's a custom style issue, I think it is a DIV setHeight on resize problem.
However, I made a short GWTP-Demo. Unfortunately, I can't provide the whole GWTP-Project.
But I can give you the necessary demo GWTP-Bunch.

NOTE1: The problem is only at tables with categories.
NOTE2: The Workaround in TestTab2View --> CustomCategoryComponent works not for all situation.
(See GIF: resize Window)
subheader.setHeight("45px"); // Workaround for row override problem

The demo has a MAIN_SOLT and two TAB-SLOTS(SLOT_TAB1, SLOT_TAB2):
TAB1: (TestTab1Presenter): is only a Dummy-Tab (no function but necessary)
TAB2: (TestTab2Presenter): load the persons onBind.

2 Person
person

Using GMD 2.0-rc5
Thanks
categorytable

Modul: TestModule, TestPresenter, TestView, TestView.ui

public class TestModule extends AbstractPresenterModule {
  @Override
  protected void configure() {
    install(new TestTab2Module());
    install(new TestTab1Module());
    bindPresenter(TestPresenter.class, TestPresenter.MyView.class, TestView.class, TestPresenter.MyProxy.class);
  }
}


public class TestPresenter extends Presenter<TestPresenter.MyView, TestPresenter.MyProxy> {

  public static final Slot<PresenterWidget<?>> SLOT_TAB1 = new Slot<>();
  public static final Slot<PresenterWidget<?>> SLOT_TAB2 = new Slot<>();

  private final TestTab1Presenter testTab1Presenter;
  private final TestTab2Presenter testTab2Presenter;

  interface MyView extends View {
  }

  @NameToken(NameTokens.TEST)
  @ProxyStandard
  interface MyProxy extends ProxyPlace<TestPresenter> {
  }

  @Inject
  TestPresenter(EventBus eventBus, MyView view, MyProxy proxy,
                TestTab1Presenter testTab1Presenter, TestTab2Presenter testTab2Presenter) {
    super(eventBus, view, proxy, ApplicationPresenter.SLOT_MAIN);
    this.testTab1Presenter = testTab1Presenter;
    this.testTab2Presenter = testTab2Presenter;
  }
  // Only for Menu-Title
  @Override
  protected void onReveal() {
    super.onReveal();
    SetMenuBarTitleEvent.fire("Test", this);
  }

  @Override
  protected void onBind() {
    super.onBind();
    setInSlot(SLOT_TAB1, testTab1Presenter);
    setInSlot(SLOT_TAB2, testTab2Presenter);
  }
}

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
             xmlns:m="urn:import:gwt.material.design.client.ui"
>
  <m:MaterialPanel ui:field="panel" marginTop="64">
    <m:MaterialColumn grid="s12">
      <m:MaterialTab ui:field="testTab" type="ICON" backgroundColor="BLUE_GREY_LIGHTEN_5"
                     indicatorColor="BLUE_DARKEN_3">
        <m:MaterialTabItem ui:field="tab1Item" waves="DEFAULT">
          <m:MaterialLink text="Dummy" href="#tab1" textColor="BLACK" />
        </m:MaterialTabItem>
        <m:MaterialTabItem ui:field="tab2Item" waves="DEFAULT">
          <m:MaterialLink text="Persons" href="#tab2" textColor="BLACK" iconType="EQUALIZER"/>
        </m:MaterialTabItem>
      </m:MaterialTab>
    </m:MaterialColumn>

    <m:MaterialColumn m:id="tab1" grid="s12">
      <m:MaterialRow>
        <m:MaterialPanel ui:field="tab1Panel"/>
      </m:MaterialRow>
    </m:MaterialColumn>
    <m:MaterialColumn m:id="tab2" grid="s12">
      <m:MaterialPanel ui:field="tab2Panel"/>
    </m:MaterialColumn>
  </m:MaterialPanel>
</ui:UiBinder>


public class TestView extends ViewImpl implements TestPresenter.MyView {

  interface Binder extends UiBinder<MaterialPanel, TestView> {
  }

  @UiField
  MaterialPanel tab1Panel, tab2Panel;
  @UiField
  MaterialTabItem tab1Item, tab2Item;

  @Inject
  TestView(Binder binder) {
    initWidget(binder.createAndBindUi(this));
    bindSlot(TestPresenter.SLOT_TAB1, tab1Panel);
    bindSlot(TestPresenter.SLOT_TAB2, tab2Panel);
  }
}

Modul: TestTab2Module, TestTab2Presenter, TestTab2View, TestTab2View.ui

public class TestTab2Module extends AbstractPresenterModule {
  @Override
  protected void configure() {
    bindPresenterWidget(TestTab2Presenter.class, TestTab2Presenter.MyView.class, TestTab2View.class);
  }
}


public class TestTab2Presenter extends PresenterWidget<TestTab2Presenter.MyView> implements TestTab2UiHandlers {

  private final RestDispatch dispatcher;
  private final TestSearchService testSearchService;

  interface MyView extends View, HasUiHandlers<TestTab2UiHandlers> {
    void setSearchTableData(List<TestDTO> result);
  }

  @Inject
  TestTab2Presenter(EventBus eventBus, MyView view, RestDispatch dispatcher, TestSearchService testSearchService) {
    super(eventBus, view);
    this.dispatcher = dispatcher;
    this.testSearchService = testSearchService;

    getView().setUiHandlers(this);
  }

  @Override
  protected void onBind() {
    super.onBind();
    dispatcher.execute(testSearchService.getPersons(), new AsyncCallback<List<TestDTO>>() {
      @Override
      public void onFailure(Throwable caught) {
        // Catch Failure
      }

      @Override
      public void onSuccess(List<TestDTO> result) {
        // REST-Response from DB all Person categorized
        // Category --> Simth
        // Category --> Bar
        getView().setSearchTableData(result);
      }
    });
  }
}

public class TestTab2View extends ViewWithUiHandlers<TestTab2UiHandlers> implements TestTab2Presenter.MyView {
  interface Binder extends UiBinder<HTMLPanel, TestTab2View> {
  }

  @UiField
  MaterialDataTable<TestDTO> table;

  @Inject
  TestTab2View(Binder binder) {
    initWidget(binder.createAndBindUi(this));

    table.setLoadedCallback(() -> {
      // We will define our own person row factory to generate the
      // category name. This can be used to generate your own
      // RowComponent's too, if custom functionality is required.
      table.setRowFactory(new TestPersonRowFactory());

      // If we want to generate all our categories using CustomCategoryComponent
      // We can define our own CategoryComponentFactory. There we can define our
      // own CategoryComponent implementations.
      table.setCategoryFactory(new TestPersonCategoryFactory());

      // Add the tables columns
      table.addColumn(new TextColumn<TestDTO>() {
        @Override
        public String getValue(TestDTO object) {
          return object.getFirstname();
        }
      }, "Firstname");

      table.addColumn(new TextColumn<TestDTO>() {
        @Override
        public String getValue(TestDTO object) {
          return object.getName();
        }
      }, "Name");

      table.addColumn(new TextColumn<TestDTO>() {
        @Override
        public HideOn getHideOn() {
          return HideOn.fromStyleName("hide-on-med-and-up");
        }

        @Override
        public String getValue(TestDTO object) {
          return String.valueOf(object.getId());
        }
      }, "Pers-ID");

    });
    //table.setDestroyOnUnload(false);
  }

  public void setSearchTableData(List<TestDTO> result) {
    table.setVisibleRange(0, result.size());
    table.setRowData(0, result);
    table.refreshView();
  }

  public static class CustomCategoryComponent extends CategoryComponent {
    public CustomCategoryComponent(String category) {
      super(category);
    }

    @SuppressWarnings("Duplicates")
    @Override
    protected void render(TableSubHeader subheader) {
      super.render(subheader);

      //subheader.setHeight("45px");    // Workaround for row override problem comment off if you need

      subheader.setTextColor(Color.BLUE_DARKEN_1);
      subheader.setOpenIcon(IconType.FOLDER_OPEN);
      subheader.setCloseIcon(IconType.FOLDER);
    }
  }

  public class TestPersonRowFactory extends RowComponentFactory<TestDTO> {
    @Override
    public RowComponent<TestDTO> generate(TestDTO model) {
      // We won't change the way it loads the RowComponent
      return super.generate(model);
    }
    @Override
    public String getCategory(TestDTO model) {
      // We want to override the standard category retrieval
      // This is where we can define a models category.
      // This is useful when we don't want to pollute our
      // object models with the interface HasDataCategory.
      return model.getCategory();
    }
  }

  public class TestPersonCategoryFactory extends CategoryComponentFactory {
    @Override
    public CategoryComponent generate(String categoryName) {
      CategoryComponent category = super.generate(categoryName);
      if (!(category instanceof CategoryComponent.OrphanCategoryComponent)) {
        category = new TestTab2View.CustomCategoryComponent(categoryName);
      }
      return category;
    }
  }
}

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
             xmlns:m="urn:import:gwt.material.design.client.ui"
             xmlns:m.table="urn:import:gwt.material.design.client.ui.table"
             xmlns:g='urn:import:com.google.gwt.user.client.ui'>
  <g:HTMLPanel>
    <m:MaterialRow>
      <m.table:MaterialDataTable m:id="customTable" ui:field="table"
                                 height="calc(50vh)"
                                 useStickyHeader="true"
                                 useCategories="true"
                                 useRowExpansion="false"
                                 selectionType="SINGLE"/>
    </m:MaterialRow>
  </g:HTMLPanel>
</ui:UiBinder>

Modul: TestTab1Module, TestTab1Presenter, TestTab1View, TestTab1View.ui

public class TestTab1Module extends AbstractPresenterModule {
  @Override
  protected void configure() {
    bindPresenterWidget(TestTab1Presenter.class, TestTab1Presenter.MyView.class, TestTab1View.class);
  }
}

public class TestTab1Presenter extends PresenterWidget<TestTab1Presenter.MyView> implements TestTab1UiHandlers {

  interface MyView extends View, HasUiHandlers<TestTab1UiHandlers> {
  }

  @Inject
  TestTab1Presenter(EventBus eventBus, MyView view) {
    super(eventBus, view);

    getView().setUiHandlers(this);
  }
}

public class TestTab1View extends ViewWithUiHandlers<TestTab1UiHandlers> implements TestTab1Presenter.MyView {
  interface Binder extends UiBinder<HTMLPanel, TestTab1View> {
  }

  @Inject
  TestTab1View(Binder binder) {
    initWidget(binder.createAndBindUi(this));
  }
}

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
             xmlns:m="urn:import:gwt.material.design.client.ui"
             xmlns:g='urn:import:com.google.gwt.user.client.ui'>
  <g:HTMLPanel>
    <m:MaterialRow addStyleNames="code">
      <m:MaterialColumn grid="s12">
        <m:MaterialLabel text="DUMMY - TAB"/>
      </m:MaterialColumn>
    </m:MaterialRow>
  </g:HTMLPanel>
</ui:UiBinder>

Modul: TestDTO

public class TestDTO {

  private long id;
  private String firstname;
  private String name;
  private String category;

  public TestDTO() {
  }

  // Getter and Setter .....
}

from gwt-material-table.

BenDol avatar BenDol commented on June 29, 2024

Haven't been able to reproduce this. Unless a sample to reproduce this issue is posted I will be closing the issue.

from gwt-material-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.