0

Gridcell is not updating with fresh content

Hi,

I am facing very strange problem. Kindly someone guide me one the same.

I am creating a 3 level of Views (sidebar).
Main Category (View A) - > Sub Category (View cool.gif - > List of data in subcategory (View C).

I am using "this.persist" method to pass the variable from one view to another and show the grid cell data accordingly. On "Back", it is going back to the "Previous Screen".

Now The problem is as follows:
By pressing "Back", I reach to (view A). This has grid cell with list of categories. I select any other category, which is loading "View B" but data is not getting updated in that gridcell. It shows old data. (I could actually check new data in Terminal window).

I even tried "_this.controls.listGrid.changeDataset([], true);" in "updateView".

What is wrong thing I am doing here? anybody help plzzz....

by
9 Replies
  • QUOTE (sharmeela @ Jun 2 2011, 11:41 PM) <{POST_SNAPBACK}>
    I even tried "_this.controls.listGrid.changeDataset([], true);" in "updateView".

    What is wrong thing I am doing here? anybody help plzzz....


    This was coverred in another post. Don't use updateView - it only gets called after a view is created. Use the onSelectView event. Some lines to help here:

    events.handleonSelectView.subscribeTo(KONtx.application, "onSelectView");

    handleonSelectView: function(event) {
    if (event.payload.viewId === "view-List") {
    event.payload.view.selectView();
    }
    },

    in my view class I have a function called selectView that does all the stuff you might have put in updateView.
    0
  • Hey mockware,

    Many Thanks for reply. I tried to use your method, but it is still not showing me any results.

    I created this in "init.js"
    events.handleonSelectView.subscribeTo(KONtx.application, "onShowView");

    In screen B - I changed the code as follows:
    CODE
    var _this;
    var elemLen=3;
    var SubCatView = new KONtx.Class({
    ClassName: 'SubCatView',

    Extends: KONtx.system.SidebarView,

    config: {
    visibleRows: elemLen,
    },

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

    var __baseID = (this.id||this.ClassName||this._ktxID+'.CategoryGrid');
    var buttonHeight = KONtx.utility.scale(35);

    var backButton = new KONtx.control.BackButton({
    id: __baseID+'.BackButton',
    label: 'Video SubCategory' }).appendTo(this);


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

    },

    _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-C", {
    param: this.param,
    });

    }
    }
    });
    cell.textLabel = new KONtx.element.Text({
    styles: {
    color: '#FFFFFF',
    fontSize: KONtx.utility.scale(18),
    hAlign: 'left',
    vAlign: 'left',
    wrap: true
    }
    }).appendTo(cell);
    return cell;
    },

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


    handleonSelectView: function(event) {
    if (event.payload.viewId === "view-B") {
    event.payload.view.selectView();
    }
    }



    });


    function selectView(){
    ..... update function content.
    }


    It seems that my "onselectView" is not placed at proper place. Could you please rectify it?
    my view-B is generated when user clicks on gridCell and "onSelect" event is fired? I am totally confused now. Please guide me.
    0
  • QUOTE (sharmeela @ Jun 6 2011, 03:16 AM) <{POST_SNAPBACK}>
    I created this in "init.js"
    events.handleonSelectView.subscribeTo(KONtx.application, "onShowView");


    Change

    events.handleonSelectView.subscribeTo(KONtx.application, "onShowView");
    to
    SubCatView.handleonSelectView.subscribeTo(KONtx.application, "onSelectView");

    The event name is onSelectView. The function you want called is the one you subscribe to the event. The reason I had events in my code is I create a events variable that holds all my event handling functions. In fact, by you trying to have the function within the SubCatView object, you will need to make sure that gets created before you try to subscribe one of its functions to the event.

    Here is what I have in a file I call events.js for reference:

    CODE
    var events = {
    handleAppStart: function(event) {
    if (currentAppData.get('host') == null)
    currentAppData.set('host', '192.168.0.2:8080');
    if (currentAppData.get('shuffle') == null)
    currentAppData.set('shuffle', 'On');
    if (currentAppData.get('ltype') == null)
    currentAppData.set('ltype', 'album');
    if (currentAppData.get('index') == null)
    currentAppData.set('index', 0);

    },

    handleonSelectView: function(event) {
    if (event.payload.viewId === "view-List") {
    event.payload.view.selectView();
    }
    },

    };


    There is a bit of a learning curve with this stuff and I found I have to look through code to find things that are missing in the docs.
    0
  • Hi mockware,

    Thanks for the information. It was very useful.

    My issue is fixed. I was missing to initialize "this" in update/ select view which was causing the problem.
    0
  • QUOTE (mockware @ Jun 3 2011, 09:31 AM) <{POST_SNAPBACK}>
    This was coverred in another post.


    Could you point me to that other post? I can't seem to find it & am hoping it might have a little more detail. I seem to be facing a similar issue.
    0
  • QUOTE (Tony Garcia @ Jul 19 2011, 09:20 AM) <{POST_SNAPBACK}>
    Could you point me to that other post? I can't seem to find it & am hoping it might have a little more detail. I seem to be facing a similar issue.



    Here it is: http://developer.yahoo.net/forum/?showtopic=8557 Apparently I don't post enough to be allowed to insert links?
    0
  • Hi I have a similar problem, that the sidebar will not load the new content it recieves dynamically. However, when I try to do the subscribeTo line in init.js I get a sidebarview.handleonSelectView has no properties.
    Relevant Code snippets
    CODE
    handleonSelectView: function(event) {
    if (event.payload.viewId === this._viewId) {
    event.payload.view.selectView();
    }
    },

    which is in my view
    and
    CODE
    SidebarView.handleonSelectView.subscribeTo(KONtx.application, "onSelectView");

    in init.js

    I am new at this and any help would be greatly appreciated.

    Thanks
    0
  • QUOTE (hari @ Jul 23 2011, 02:17 PM) <{POST_SNAPBACK}>
    Hi I have a similar problem, that the sidebar will not load the new content it recieves dynamically. However, when I try to do the subscribeTo line in init.js I get a sidebarview.handleonSelectView has no properties.


    That statement usually means that sidebarview is not an object that has been created. Notice in my example above I use var events to create an object called events that can then have its functions attached to events. Views are not created yet so you get that error. You should create an object with functions to handle your events then use what is passed to those functions to determine what view is affected and act accordingly.
    0
  • Hi,
    you could put the full code to see the program.
    Thanks.

    QUOTE(sharmeela @ 10 Jun 2011 3:05 AM)
    Hi mockware,

    Thanks for the information. It was very useful.

    My issue is fixed. I was missing to initialize "this" in update/ select view which was causing the problem.
    0

Recent Posts

in General - Yahoo! TV Widgets