DataView(ExtJS) equivalent

I’ve used a lot the DataView class of Extjs. What would be the class in SmarClient that does what DataView does in Extjs?

Basically this class “link” one DataSource/Store to a View/Template to show records the way you want to.

I know there are examples showing how to link one DataSource to Tree, List, etc. But none of them show how to customize the way it will be shown.

For instance, in my application I have one datasource for images and want to show these images exactly the way microsft explorer shows its images when “view” is set to “Thumbnails”. How to achieve that?

ohh, I also want to be able to select this images by clicking them.

If there is any solution already avaiable: is it support reorder items by dnd? And righ-click-menu?

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"
});

Where can I find a roadmap? or a list of features that are planned?

“When” would be relevant too.

Thank you.