0

RE: Pager Breaks - NEW DEVELOPERS READ THIS :) !!!

I was having an issue with the pager, and was crying for three days. I'm a decent programmer, but I know there are many that are much better.

I figured out how to use pager in it's most basic form - and here are some comical bits of knowledge that would have helped me to resolve this days ago...

1. If you want to remove all of the extra debug info from the console, you can go to the Simulator Settings option from the same area where you launch the simulators, and specify a widget id to monitor, so the others are ignored. restrict_console=com.yahoo.widgets.tv.finance. Here's the fun part - if you are ADHD like me, and have a few versions of your widget floating around, very unorganized, make sure and update that restrict line if you change your widget id, or for 2 days you will go nuts trying to figure out why your code isn't sending the most simple logs. This would have saved me days ago wink.gif

2. My php was sending result = (a bunch of json encoded array data) . I noticed in all of the examples for pager that they were using

handleFetchResponse: function(u) {

then doing something with u.result. I thought php had to return result=xxxx. As soon as I figured out that 'result' was a property of that JSON object, it all worked. Yes, I'm stupid, but hey - I have a pager function working correctly after 2-3 days.

Below is my dummied down code for anyone making their first pager......

A question - I based my pager functions off another demo I found here in the forums. I noticed that it is missing -> pager: my_pager; in the grid definition, as well as the fact that I'm not using onGotPage what so ever. Will my code below be accepted by the Yahoo guys? It works - but it seems to be different from the examples.


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

Extends: KONtx.system.SidebarView,

config: {
rows: 5,
columns: 1
},

createView: function (){

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




this.controls = {};

this.controls.backbutton = new KONtx.control.BackButton({
id: __baseID+'.BackButton',
label: 'Image Grid Test'
}).appendTo(this);


this.controls.grid = new KONtx.control.Grid({
id: __baseID+'.Grid',
rows: this.config.rows,
columns: this.config.columns,
styles: {
width: this.width,
height: this.height -
this.controls.backbutton.height,
vOffset: this.controls.backbutton.height
},
cellCreator: this.imageCellCreator,
cellUpdater: this.imageCellUpdater,
manageWaitIndicator: true
}).appendTo(this);

},


fetchData: function() {
log('fetching ');
var u = new URL();
u.location = "http://www.boyamidumb.com/test.php";
u.fetchAsync(this.handleFetchResponse.bindTo(this));
},



handleFetchResponse: function(u) {

if(u.response != 200) {
return;
}

if(this.controls.grid) {
var my_data_struct = JSON.parse(u.result);
this.controls.grid.changeDataset(my_data_struct);
}
},



updateView: function (){
this.fetchData();
},


imageCellCreator: function () {
var cell = new KONtx.control.GridCell({
styles: {
height: 35,
width: this.width,
}
});

cell.textLabel = new KONtx.element.Text({
styles: {
color: '#999999',
fontSize: KONtx.utility.scale(12),
hAlign: 'left',
vAlign: 'center',
hOffset: 170,
vOffset: 30,

}
}).appendTo(cell);

cell.posterImage = new KONtx.element.Image({
styles: {
vAlign: "center",
hAlign: "left",
width: 50,
height: 65,
hOffset: 6
}
}).appendTo(cell);

return cell;

},

imageCellUpdater: function (cell, dataitem) {
cell.posterImage.src = dataitem.src;
cell.textLabel.data = dataitem.label;
}
});

by
0 Replies

Recent Posts

in General - Yahoo! TV Widgets