0

Focus on first Grid cell not working with "FocusView"

Hi,

My widget is fetching data thru API and creating Grid Cell to show it. I wanted to focus first grid cell element and I have used "FocusView" for the same. But somehow it is not working.

Kindly provide me solution for the same.

My Code:

CODE
var myView = new KONtx.Class({
ClassName: 'myView ',

Extends: KONtx.system.SidebarView,

config: {
visibleRows: 10,
},

createView: function() {
_this = this;
this.controls = {};

var __baseID = (this.id||this.ClassName||this._ktxID+'.CategoryGrid');

var buttonHeight = KONtx.utility.scale(25);

var backButton = new KONtx.control.BackButton({
id: __baseID+'.BackButton',
label: $_("Main.ButtonLabel1") }).appendTo(this);

/*this.controls.pageindicator = new KONtx.control.PageIndicator({
id: __baseID+'.PageIndicator',
styles: {
vAlign: 'bottom',
vOffset: KONtx.utility.scale(35)
}
}).appendTo(this);

this.controls.metadata = new KONtx.control.MetadataDisplay({
id: __baseID+'.Metadata',
styles: {
height: 23,
vAlign: 'bottom',
vOffset: KONtx.utility.scale(35)
}
}).appendTo(this);*/


this.controls.listGrid = new KONtx.control.Grid({
focus: true,
columns: 1,
rows: this.config.visibleRows,
carousel: true,
cellCreator: this._cellCreator,
cellUpdater: this._cellUpdater,
styles: {
vOffset: backButton.outerHeight + buttonHeight,
width: this.width,
height: buttonHeight * this.config.visibleRows
},
manageWaitIndicator: true
}).appendTo(this);

},

focusView: function () {
this.controls.listGrid._cellUpdater({
focusCoordinates: {
row: 5,
column: 0
}
});
this.controls.listGrid.focus();
},

_cellCreator: function() {
var cell = new KONtx.control.GridCell({
styles: {
height: KONtx.utility.scale(35),
width: this.width,
},
events: {
onSelect: function(event) {
KONtx.application.loadView("view-VideoSubCat", {
VideoCatUrl: this.subCatURL,
});
}
}
});
cell.textLabel = new KONtx.element.Text({
styles: {
color: '#FFFFFF',
fontSize: KONtx.utility.scale(18),
hAlign: 'left',
vAlign: 'left'
}
}).appendTo(cell);
return cell;
},

_cellUpdater: function(cell, dataitem) {
cell.textLabel.data = dataitem.label;
cell.textImg= dataitem.textImg;
},


updateView: function() {
// function to fetch data.
}
});

by
1 Reply
  • Just cleared the code. (removed unwanted syntax.)

    My Code:

    CODE
    var myView = new KONtx.Class({
    ClassName: 'myView ',

    Extends: KONtx.system.SidebarView,

    config: {
    visibleRows: 10,
    },

    createView: function() {
    _this = this;
    this.controls = {};

    var __baseID = (this.id||this.ClassName||this._ktxID+'.CategoryGrid');

    var buttonHeight = KONtx.utility.scale(25);

    var backButton = new KONtx.control.BackButton({
    id: __baseID+'.BackButton',
    label: $_("Main.ButtonLabel1") }).appendTo(this);

    this.controls.listGrid = new KONtx.control.Grid({
    focus: true,
    columns: 1,
    rows: this.config.visibleRows,
    carousel: true,
    cellCreator: this._cellCreator,
    cellUpdater: this._cellUpdater,
    styles: {
    vOffset: backButton.outerHeight + buttonHeight,
    width: this.width,
    height: buttonHeight * this.config.visibleRows
    },
    manageWaitIndicator: true
    }).appendTo(this);

    },

    focusView: function () {
    this.controls.listGrid._cellUpdater({
    focusCoordinates: {
    row: 5,
    column: 0
    }
    });
    this.controls.listGrid.focus();
    },

    _cellCreator: function() {
    var cell = new KONtx.control.GridCell({
    styles: {
    height: KONtx.utility.scale(35),
    width: this.width,
    },
    events: {
    onSelect: function(event) {
    KONtx.application.loadView("view-VideoSubCat", {
    //pass data.
    });
    }
    }
    });
    cell.textLabel = new KONtx.element.Text({
    styles: {
    color: '#FFFFFF',
    fontSize: KONtx.utility.scale(18),
    hAlign: 'left',
    vAlign: 'left'
    }
    }).appendTo(cell);
    return cell;
    },

    _cellUpdater: function(cell, dataitem) {
    cell.textLabel.data = dataitem.label;
    cell.textImg= dataitem.textImg;
    },


    updateView: function() {
    // function to fetch data.
    }
    });

    [/quote]
    0

Recent Posts

in General - Yahoo! TV Widgets