如何在dojox.mobile.EdgeToEdgeList中创建等高列表项?

如何在dojox.mobile.EdgeToEdgeList中创建等高列表项?,dojo,dojox.mobile,Dojo,Dojox.mobile,我有一个标准的dojox.mobile.EdgeToEdge列表,里面有一组dojox.mobile.ListItems。我需要确保每个列表项的高度相等。请参见以下绘制不好的表示: 标准EdgeToEdgeList与ListItems: +-------------------+ | Standard ListItem | |-------------------| | Standard ListItem | |-------------------| | Standard ListItem |

我有一个标准的
dojox.mobile.EdgeToEdge
列表,里面有一组
dojox.mobile.ListItem
s。我需要确保每个列表项的高度相等。请参见以下绘制不好的表示:

标准
EdgeToEdgeList
ListItem
s:

+-------------------+
| Standard ListItem |
|-------------------|
| Standard ListItem |
|-------------------|
| Standard ListItem |
|-------------------|
| Standard ListItem |
+-------------------+
标准的
EdgeToEdgeList
,带有可变高度的列表项;通过在列表项上设置
variableHeight
属性来实现:

+-------------------+
| Standard ListItem |
|-------------------|
| Standard ListItem |
|-------------------|
| Standard ListItem |
| with some long    |
| text and variable |
| height that wraps |
| to next line      |
|-------------------|
| Standard ListItem |
+-------------------+
EdgeToEdgeList
具有相同高度的列表项(较小的列表项“取”最大高度):

我正在尝试复制第三个解决方案。有没有标准的方法可以做到这一点

编辑:我没有提到我正在以编程方式构建列表,因此我不知道当前最大项目的高度。像这样的东西行吗

var largest = 0;
array.forEach(list.getChildren(), function(child) {
    var childHeight = domStyle.get(child.domNode, 'height');

    largest = (childHeight > largest) ? childHeight : largest;
});

array.forEach(list.getChildren(), function(child) {
    domStyle.set(child.domNode, 'height', largest + 'px');
});

这似乎有点“hack-y”。

覆盖
.mblListItem
CSS类中的height属性

我相信默认高度是43像素

编辑:我认为您的代码可以工作,但是您需要将
列表项
设置为可变高度,以便Dojo计算每个项目的高度,然后取最大值并应用于每个项目。与您所写的类似,但添加了可变高度,然后在应用最大高度时将其删除

var largestHeight = 0;
var list = dijit.byId("list");
dojo.forEach(data, function(record) {
    var listItem = new dojox.mobile.ListItem({
        label: data.label
        variableHeight: true,
    }); 
    list.addChild(listItem); 
    var currentHeight = (dojo.style(listItem.domNode, 'height');
    largestHeight = (currentHeight > largestHeight ? currentHeight : largestHeight);
});

dojo.query('.mblListItem', dojo.byId('list')).forEach(function(node) {
    dojo.removeClass(node, 'mblVariableHeight');
    dojo.style(node, 'height', largestHeight + 'px');
});

谢谢你的回答,麦克拉格。列表是以编程方式生成的,所以我不一定知道最大列表项的高度。
var largestHeight = 0;
var list = dijit.byId("list");
dojo.forEach(data, function(record) {
    var listItem = new dojox.mobile.ListItem({
        label: data.label
        variableHeight: true,
    }); 
    list.addChild(listItem); 
    var currentHeight = (dojo.style(listItem.domNode, 'height');
    largestHeight = (currentHeight > largestHeight ? currentHeight : largestHeight);
});

dojo.query('.mblListItem', dojo.byId('list')).forEach(function(node) {
    dojo.removeClass(node, 'mblVariableHeight');
    dojo.style(node, 'height', largestHeight + 'px');
});