Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

TileGrid addData/removeData issue/bug where tile disappears

$
0
0
There seems to be a bug with the SmartClient javascript library for the TileGrid when using removeData and addData functions.

I have a tile grid from which I can remove records and add records. When I remove any record other than the last record and then try to add a record using TileGrid.addData(record), one of the existing tiles disappears.

I have reproduced this bug with one of the SmartClient's showcase examples.

I'm using SmartClient Version: SNAPSHOT_v9.1d_2013-12-11/PowerEdition Deployment 2013-12-11

This bug happens in all the latest browsers: (i.e. Chrome Version 31 on OS:Windows,Mac)

Steps to reproduce the bug:
1. Go to this link: http://www.smartclient.com/docs/9.0/...ingCustomTiles
2. Click on: customTiles.js tab.
3. Delete all javascript code in the scrollable area.
4. Paste code added below in the scrollable area.
5. Click on "Try it".
6. Delete any tile other than the last tile using the remove button on the top right of any tile.
7. Click on any "+" button on the top left of any tile (this will add a brand new tile every time to the TileGrid).
8. Look for the blank space in-between two of the tiles (usually towards the end of the TileGrid).

Code:

isc.TileGrid.create({
    ID:"boundList",
    tileWidth:150,
    tileHeight:205,
    width: "100%",
    height:"100%",
    dataSource:"animals",
    autoFetchData:true,
    animateTileChange:true,
    fields: [
        {name:"picture"},
        {name:"commonName", cellStyle: "commonName"},
        {name:"lifeSpan", formatCellValue: "return 'Lifespan: ' + value;"},
        {  name:"status",
            getCellStyle: function (value, field, record, viewer) {
                if (value == "Endangered") return "endangered";
                else if (value == "Threatened") return "threatened";
                else if (value == "Not Endangered") return "notEndangered";
                else return viewer.cellStyle;
            }
        }
    ],

    getTile : function (record) {
        // override getTile() and add a "Remove" button
        var canvas = this.Super("getTile", arguments);
        canvas.addChild(this.getRemoveButton(this.getRecord(record)));
        canvas.addChild(this.getAddButton(this.getRecord(record)));
        return canvas;
    },
   
    getRemoveButton : function (record) {
        var removeButton = isc.ImgButton.create({
            src: "[SKINIMG]/Tab/left/close.png",
            showHover: true,
            prompt: "Remove tile",
            size: 15,
            showFocused: false,
            showRollOver: false,
            snapTo: "TR",
            showDown: false,
            margin: 2,
            tileGrid: this,
            record: record,
            click : function () {
                animals.removeData(this.record);
            }
        });

        return removeButton;
    },

  getAddButton : function (record) {
        var addButton = isc.Button.create({
            src: "[SKINIMG]/Tab/left/add.png",
            title:'+',
            showHover: true,
            prompt: "Add tile",
            size: 20,
            showFocused: false,
            showRollOver: false,
            snapTo: "TL",
            showDown: false,
            margin: 2,
            tileGrid: this,
            record: record,
            click : function () {
                animals.addData({
                          scientificName : "blah" + Math.random(), picture : "HowlerMonkey.jpg",
                          commonName : "tempTile", lifeSpan : 100, status : "Protected"
                });
            }
        });

        return addButton;
    }

});


Viewing all articles
Browse latest Browse all 4756

Latest Images

Trending Articles



Latest Images