简体   繁体   English

如何获取表格以显示图像

[英]How do I get a table to display images

I am building a table in Seaside (Using VisualAge Smalltalk). 我在Seaside中建立表格(使用VisualAge Smalltalk)。 I would like to have each table row have an image as well as text data. 我希望每个表行都有一个图像以及文本数据。 This what the method looks like: 该方法如下所示:

where PSIni getImageUrl returns the main part of the url . 其中PSIni getImageUrl返回url的主要部分。 The final url looks like http://www.totallyobjects.com/images/pennstadt//15.jpg 最终url看起来像http://www.totallyobjects.com/images/pennstadt//15.jpg

Can anyone point me as to how to get this done please? 谁能指出我如何完成这项工作?

 makeData: html usingMethod: aMethod

|tableData headingList methodList|

tableData := self perform: aMethod.
headingList := self headingList.
methodList := self methodList.

html table: [ 
    html tableRow: [ 
        headingList do: [ :each | html 
            tableHeading: each 
        ]
    ].
    tableData do: [ :one |          
        html tableRow: [
            methodList do: [ :each | 
                each = #image ifTrue: [ 
                    html tableData: (self showImageFor: one id using: html)
                ] ifFalse: [ 
                    html tableData: (one perform: each)                        
                ]
            ]
        ]
    ]
]

(self showImageFor: one id using: html) obviously doesn't work. (self showImageFor: one id using: html)显然不起作用。 This method looks like this: 此方法如下所示:

showImageFor: anID using: html

html image width: 200; url: PSIni getImageURL, '/', anID printString, '.jpg'

where PSIni getImageUrl returns the main part of the url . 其中PSIni getImageUrl返回url的主要部分。

The final url looks like: http://www.totallyobjects.com/images/pennstadt/15.jpg and should result in that image appearing in one element of a table row. 最终的url看起来像: http : //www.totallyobjects.com/images/pennstadt/15.jpg,并且应该导致该图像出现在表行的一个元素中。

You need to nest the brushes: 您需要嵌套画笔:

html tableData: [ (self showImageFor: one id using: html) ]

It's explained in depth in the book: http://book.seaside.st/book/fundamentals/rendering-components 本书对此进行了详细说明: http : //book.seaside.st/book/fundamentals/rendering-components

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM