<legend id='UmwNy'><style id='UmwNy'><dir id='UmwNy'><q id='UmwNy'></q></dir></style></legend>

<i id='UmwNy'><tr id='UmwNy'><dt id='UmwNy'><q id='UmwNy'><span id='UmwNy'><b id='UmwNy'><form id='UmwNy'><ins id='UmwNy'></ins><ul id='UmwNy'></ul><sub id='UmwNy'></sub></form><legend id='UmwNy'></legend><bdo id='UmwNy'><pre id='UmwNy'><center id='UmwNy'></center></pre></bdo></b><th id='UmwNy'></th></span></q></dt></tr></i><div id='UmwNy'><tfoot id='UmwNy'></tfoot><dl id='UmwNy'><fieldset id='UmwNy'></fieldset></dl></div>

    <small id='UmwNy'></small><noframes id='UmwNy'>

    • <bdo id='UmwNy'></bdo><ul id='UmwNy'></ul>
    <tfoot id='UmwNy'></tfoot>

      1. Vaadin Grid 单元格未显示多行行

        时间:2024-08-24
        <legend id='za4OU'><style id='za4OU'><dir id='za4OU'><q id='za4OU'></q></dir></style></legend>
        1. <tfoot id='za4OU'></tfoot>
        2. <small id='za4OU'></small><noframes id='za4OU'>

          • <i id='za4OU'><tr id='za4OU'><dt id='za4OU'><q id='za4OU'><span id='za4OU'><b id='za4OU'><form id='za4OU'><ins id='za4OU'></ins><ul id='za4OU'></ul><sub id='za4OU'></sub></form><legend id='za4OU'></legend><bdo id='za4OU'><pre id='za4OU'><center id='za4OU'></center></pre></bdo></b><th id='za4OU'></th></span></q></dt></tr></i><div id='za4OU'><tfoot id='za4OU'></tfoot><dl id='za4OU'><fieldset id='za4OU'></fieldset></dl></div>

              • <bdo id='za4OU'></bdo><ul id='za4OU'></ul>
                  <tbody id='za4OU'></tbody>
                  本文介绍了Vaadin Grid 单元格未显示多行行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 Vaadin Grid,我想为每个单元格生成多行单元格,这些单元格中的内容与宽度重叠.

                  With Vaadin Grid, I want to generate multiline cells for every cell that have more content in cell that overlaps its width.

                  我已经试过了:

                  • java 换行符和 CSS 样式,如 white-space: pre; 但它似乎不起作用.(此解决方案适用于 Table)

                  • java new line character and CSS stylings like white-space: pre; but it does not seem to work. (This solution worked for Table)

                  自定义渲染器 setRenderer(HtmlRenderer) 带有 </br>标签和不同的 CSS 显示设置

                  custom renderer setRenderer(HtmlRenderer) with </br>tags and different CSS display settings

                  期望的结果:

                  推荐答案

                  对于列中有大文本并且希望在网格列中显示大数据而不默认截断它们的人:

                  For people with large text in columns and who want to display large data in Grid Columns without having them cutoff by default:

                  1. 为您的网格添加样式名称:

                  1. Add a Style name to your grid:

                  grid.addStyleName("commentsGrid");

                  如果您想自定义它们,请为您的行和单元格添加一些样式名称:

                  Add some style names to your rows and cells if you would like to customize them:

                  grid.setRowStyleGenerator(rowRef -> {// Java 8
                      return "bigRows";
                  }); 
                  

                  grid.setCellStyleGenerator(new Grid.CellStyleGenerator(){
                       @Override
                       public String getStyle(CellReference cellReference) {
                           return "bigCell";
                       }
                  });
                  

                • 对我来说,问题栏是评论.因此,使用样式类 wrap 和固定宽度的 p 标签围绕文本.

                • For me the problem column was comments. So surround the text with p tag with style class wrap and a fixed width.

                  Converter<String, String> commentsConverter = new Converter<String,  String>(){
                          @Override
                          public String convertToModel(String value, Class<? extends String> targetType, Locale locale)
                                  throws com.vaadin.data.util.converter.Converter.ConversionException {
                  
                              return value;
                          }
                  
                          @Override
                          public String convertToPresentation(String value, Class<? extends String> targetType, Locale locale)
                                  throws com.vaadin.data.util.converter.Converter.ConversionException {
                              if(value !=null){
                                  return "<p class="wrap">"+value+"</p>";
                              }else{
                                  return "";
                              }
                          }
                  
                          @Override
                          public Class<String> getModelType() {
                              return String.class;
                          }
                  
                          @Override
                          public Class<String> getPresentationType() {
                              return String.class;
                          }
                  
                      };
                      grid.getColumn("comments").setRenderer(new HtmlRenderer(), commentsConverter);
                      grid.getColumn("comments").setWidth(700d);
                  

                • 然后我将上面提到的类设置如下:

                • Then i styled the classes mentioned above as follows:

                  .commentsGrid td{
                      height:150px !important;
                   }
                  
                  p.wrap{
                    width: 45em;
                    word-wrap: break-word;
                    word-break: break-all;
                    white-space: normal; 
                  }
                  

                • 我得到了这样的结果:

                  我不是 CSS 忍者,所以你可以让它比这更漂亮.

                  I am not a CSS ninja, so you can make it way more beautiful than this.

                  如果您不希望所有行都具有同样大的高度,那么您可以即时计算 rowHeights,然后在第 2 步中设置它们.我不是 100% 确定.

                  If you don't like all rows to have equally large heights then you can calculate rowHeights on the fly and then set them in step 2. I am not 100% sure.

                  这篇关于Vaadin Grid 单元格未显示多行行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:GridView 在触摸时获取项目 下一篇:网格窗格可以自动调整其对象的大小以适合吗?尝试将 max_width 和 max_height 设置为网格并让它调整内容

                  相关文章

                • <tfoot id='0tTiF'></tfoot>

                  <i id='0tTiF'><tr id='0tTiF'><dt id='0tTiF'><q id='0tTiF'><span id='0tTiF'><b id='0tTiF'><form id='0tTiF'><ins id='0tTiF'></ins><ul id='0tTiF'></ul><sub id='0tTiF'></sub></form><legend id='0tTiF'></legend><bdo id='0tTiF'><pre id='0tTiF'><center id='0tTiF'></center></pre></bdo></b><th id='0tTiF'></th></span></q></dt></tr></i><div id='0tTiF'><tfoot id='0tTiF'></tfoot><dl id='0tTiF'><fieldset id='0tTiF'></fieldset></dl></div>

                  <legend id='0tTiF'><style id='0tTiF'><dir id='0tTiF'><q id='0tTiF'></q></dir></style></legend>

                    <bdo id='0tTiF'></bdo><ul id='0tTiF'></ul>
                  1. <small id='0tTiF'></small><noframes id='0tTiF'>