如何根据列的最大大小动态设置 YUI 数据表的宽度

发布于 2024-11-19 23:54:04 字数 590 浏览 5 评论 0原文

我有一个 YUI 数据表,我将以下数据放入表中:

 {key:"name", label:"name", editor: nameChoiceEditor},
 {key:"group", label:"group", editor: groupChoiceEditor},
 {key:"colony", label:"colony", width: 210, editor: colonyChoiceEditor},
 ...

这里 name 列的宽度设置为为该名称输入的字符的最大长度,与 group< /代码>。无论数据长度如何,colony 的列宽均设置为 210。

我的问题是,当 name 列包含多个单词(如“odaiah chitukuri”)时,显示在两行中,如下所示:

  odaiah
  chitukuri

但是当它是一个单词(如“odaiahchitukuri”)时,它显示在一行中,意味着该列正在调整以适应单词。

我应该在单行中包含不同的单词。怎么做呢?

I have a YUI datatable and I am putting the following data in the table:

 {key:"name", label:"name", editor: nameChoiceEditor},
 {key:"group", label:"group", editor: groupChoiceEditor},
 {key:"colony", label:"colony", width: 210, editor: colonyChoiceEditor},
 ...

Here the name column's width is set to the maximum length of characters entered for that name, and the same with group. colony's column width is set to 210 irrespective of the length of the data.

My problem is when the name column, having multiple words like "odaiah chitukuri", is showing in two lines like so:

  odaiah
  chitukuri

But when it is one word like "odaiahchitukuri" it is showing in a single line, meaning the column is adjusting to fit the word.

I should have the different words in sigle line. How to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

如若梦似彩虹 2024-11-26 23:54:04

将“中断”空格替换为不间断空格。

尝试以下操作:

更改:

{key:"colony", label:"colony", width: 210, editor: colonyChoiceEditor},

至:

{key:"colony", label:"colony", width: 210, editor: colonyChoiceEditor
  formatter: function (el, oRecord, oColumn, oData) {
    el.innerHTML = oData.replace(/ /g, ' ');
  }
},

Have the 'breaking' spaces replace with non-breaking spaces.

Try the following:

Change:

{key:"colony", label:"colony", width: 210, editor: colonyChoiceEditor},

To:

{key:"colony", label:"colony", width: 210, editor: colonyChoiceEditor
  formatter: function (el, oRecord, oColumn, oData) {
    el.innerHTML = oData.replace(/ /g, ' ');
  }
},
小猫一只 2024-11-26 23:54:04

我不确定您是否正在寻找一种始终将单词保留在一行上的解决方案。但一般来说,数据表在根据内部内容正确间隔列方面做得很好。但在某些情况下,我肯定必须手动设置列的宽度。以下是带有类 appicon 的列的示例:

.yui-skin-sam .yui-dt tbody td.appicon {
    width: 40px;
}

请记住,一旦列中的单词数超出其定义的大小,它将始终移动到下一行。

I'm not sure if your looking for a solution that will always keep the words on a single line.. but generally speaking the datatable does a good job of spacing out the columns correctly based on the content inside. In certain cases though I've definitely had to set the width of a column manually. Here is an example for a column with class appicon:

.yui-skin-sam .yui-dt tbody td.appicon {
    width: 40px;
}

Bare in mind once the number of words in the column stretches past it's defined size, it will always move to the next line.

樱娆 2024-11-26 23:54:04

在数据表列中定义:

  • 将为 width:100
  • 而不是 width:"100px"
  • width:"100"
  • width:" 100em"

使用宽度:100

这样的话它对我来说工作得很好

In datatable column define :

  • will be width:100
  • not width:"100px"
  • or width:"100"
  • or width:"100em"

Use width: 100

like that then its working fine for me

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文