Hi Krycheck,
SmartClient doesn’t have a directly corresponding component, although one is planned. See below for an example of a custom component that implements a view similar to what you describe, which could be easily extended to, eg, allow arbitrary contents for each tile via using an HTMLFlow and a formatter function.
// TiledView
//
// Shows a set of tiled thumbnails.
//------------------------------------------------------------------------------
isc.defineClass("TiledView", "VStack").addProperties({
//border: "1px solid grey",
overflow: "hidden",
tileMargin: 3,
tileMinSize: 40,
// xpath to apply to each data element to locate the URL to the image.
imageXPath: "PictureDetails/GalleryURL",
setTileMargin : function (tileMargin) {
if (tileMargin == this.tileMargin) return;
this.tileMargin = tileMargin;
this.rebuildStacks();
},
setTileMinSize : function (tileMinSize) {
if (tileMinSize == this.tileMinSize) return;
this.tileMinSize = tileMinSize;
this.rebuildStacks();
},
initWidget : function () {
this.Super("initWidget", arguments);
this.membersMargin = this.tileMargin;
this.setData(this.data);
},
setData : function (newData) {
if (this.data == newData) return;
if (this.data) this.ignore(this.data, "dataChanged");
this.data = newData;
if (this.data) {
this.observe(this.data, "dataChanged", "observer.dataChanged()");
}
this.dataChanged();
},
resized : function () {
this.Super("resized", arguments);
this.rebuildStacks();
},
dataChanged : function () {
this.rebuildStacks();
this.markForRedraw();
},
rebuildStacks : function () {
// if data has been wiped out, just destroy our members
this.destroyMembers();
if (!this.data) return;
// total number of images
var totalImages = this.data.length;
var width = this.getWidth(), height = this.getHeight();
// calculations are based on the formula:
// size * numImages + margin * (numImages - 1) = width (or height)
// max images we can fit width/height wise at smallest size
var maxW = Math.floor((width+this.tileMargin)/(this.tileMinSize+this.tileMargin));
var maxH = Math.floor((height+this.tileMargin)/(this.tileMinSize+this.tileMargin));
// max tileSize for each axis given the max images for that axis.
var tileSizeW = Math.floor((width-(this.tileMargin*(maxW-1)))/maxW);
var tileSizeH = Math.floor((height-(this.tileMargin*(maxH-1)))/maxH);
// take the minimum of the calculated tileSize for each axis
var tileSize = Math.min(tileSizeW, tileSizeH);
var tileW = maxW;
var tileH = maxH;
// this.logWarn("tileSize: " + tileSize + ", tileW: " + tileW + ", tileH: " + tileH);
// build up a new series of HStacks with images.
var tileNum = 0;
for (var i = 0; i < tileH && tileNum < totalImages; i++) {
var hStack = isc.HStack.create({
autoDraw: false,
membersMargin: this.tileMargin,
width: width,
height: tileSize
});
for (var j = 0; j < tileW; j++) {
var tileProps = this.data[tileNum++];
hStack.addMember(this.makeTile(tileProps, tileSize));
// check for the case where more images are returned than will fit
if (tileNum >= totalImages) break;
}
this.addMember(hStack);
// check for the case where more images are returned than will fit
if (tileNum >= totalImages) break;
}
},
destroyMembers : function () {
// destroy all member VStacks and their children
var members = this.getMembers();
while (members.length) members[0].destroy();
},
makeTile : function (tileProps, tileSize) {
var src = isc.xml.selectObjects(tileProps, this.imageXPath, true);
return isc.Img.create({
src: src,
border: "1px solid black",
canHover: true,
size: tileSize,
tiledView: this,
handleHover : function () {
if (this.tiledView.itemHover) this.tiledView.fireCallback("itemHover", "item", [this]);
},
click : function () {
if (this.tiledView.itemClick) this.tiledView.fireCallback("itemClick", "item", [this]);
}
}, tileProps);
},
search : function (searchString) {
// do the search, restrict results to only those in the gallery so we have a
// thumbnail to show.
searchItemListingsDS.filterData({Query: searchString, SearchType: "Gallery"},
this.getID()+".searchCallback(data)", {promptStyle: "cursor"});
},
searchCallback : function (data) {
this.setData(data);
}
});
isc.TiledView.registerStringMethods({
itemHover : "item",
itemClick : "item"
});