0

how to pass variable

Hey!!

How to pass variable on select event of imageCellCreator?

ImageCellCreator: function() {
return new KONtx.control.PhotoGridCell({
styles: this.getCellDimensions(),
events: {
onSelect: function (event){
var m = 88;
KONtx.application.loadview('view-Sub2', { foo: m });
}
}
});
},

in this code i am able to pass 88 on view-sub2. but if i want to pass image id or gridcell id like 1 then on select of 2nd it will pass 2 and on 3rd image in cell when i select it will pass 3 on view-sub. how can i do this?

onSelect: function (event){
var dataItemNumber = this.getCellDataIndex() + 1;
log('selected a photo in cell number: '+dataItemNumber);
}

this is also not works as define in pdf file for developer.

please help me i think it is simple but i can't found sol. for this. help me plz....
Thanks.

by
6 Replies
  • you would do it actually in the imageUpdater function

    CODE
    ImageCellCreator: function() {
    return new KONtx.control.PhotoGridCell({
    styles: this.getCellDimensions(),
    events: {
    onSelect: function (event){
    var m = 88;
    KONtx.application.loadview('view-Sub2', { foo: this.info });
    }
    }
    });
    },
    imageUpdater: function(cell,data){
    cell.info = data;
    }


    For more examples, checkout/signup our Developer Toolkit at http://www.widgetrealm.com/developers

    We have A few examples that work with grids and setting the data for the cell. Check out the RSS feed example or the JSON feed example.

    Hope this helps.
    0
  • Thanks for replay.
    But i used same code and pass this.info as variable named foo. and when i retrieve the foo in next screen it will print nothing. so may be value of foo is null in this case so it will not print nothing. soory but still i am in trouble. could you please explain more?
    0
  • It is virtually impossible to diagnose your issues without seeing the full context of how you are using your code...
    0
  • QUOTE (WidgetRealm @ Oct 28 2010, 08:04 AM) <{POST_SNAPBACK}>
    It is virtually impossible to diagnose your issues without seeing the full context of how you are using your code...

    sorry for that.. here is the code

    //start step
    // cell create/update methods get fired in context of grid
    imageCellCreator: function () {
    return new KONtx.control.PhotoGridCell({
    styles: this.getCellDimensions(),
    events: {
    // this onSelect fires in context of cell
    onSelect: function (event){
    //KONtx.application.loadView('view-Sub2');
    var m = this.getCellDataIndex();
    KONtx.application.loadView('view-Sub2', { foo: m });
    }
    }
    });
    },

    imageCellUpdater: function (cell, dataitem) {
    cell.setSources(dataitem);
    }
    //end of step

    o.k.? what i want in gridcell when i press first image it will display full description of that image from xml file. but for that i have to pass id of that image to next screen. right? for image 2 it will pass m = 2 for image3 in gridview it will go next screen with m =3. like we pass variable in page as demo.php?x=2 samething i want to do in this case.
    or anyt other way to get this. means my goal is to disply info of perticular image in next screen when i press on image.

    Thanks
    0
  • QUOTE (DEEPKUMAR @ Oct 28 2010, 11:32 AM) <{POST_SNAPBACK}>
    sorry for that.. here is the code

    //start step
    // cell create/update methods get fired in context of grid
    imageCellCreator: function () {
    return new KONtx.control.PhotoGridCell({
    styles: this.getCellDimensions(),
    events: {
    // this onSelect fires in context of cell
    onSelect: function (event){
    //KONtx.application.loadView('view-Sub2');
    var m = this.getCellDataIndex();
    KONtx.application.loadView('view-Sub2', { foo: m });
    }
    }
    });
    },

    imageCellUpdater: function (cell, dataitem) {
    cell.setSources(dataitem);
    }
    //end of step

    o.k.? what i want in gridcell when i press first image it will display full description of that image from xml file. but for that i have to pass id of that image to next screen. right? for image 2 it will pass m = 2 for image3 in gridview it will go next screen with m =3. like we pass variable in page as demo.php?x=2 samething i want to do in this case.
    or anyt other way to get this. means my goal is to disply info of perticular image in next screen when i press on image.

    Thanks

    You really need to start wrapping your code in code tags.

    Basically, there are two ways to dynamically retrieve the data you need in the onSelect listener. One, having bound the data directly to the cell control as an expando property in the imageCellUpdater method, you can access it as this.myProperty within the onSelect listener. Or, you can access the data within the payload object in event.payload.dataItem. It doesn't matter what you do. It all depends on the data structure that you've passed when calling [grid].changeDataset.

    Run the following code to see how the data is being passed:

    CODE
    ImageCellCreator: function() {
    return new KONtx.control.PhotoGridCell({
    styles: this.getCellDimensions(),
    events: {
    onSelect: function (event){
    log("____________________________________________");
    log("____________________________________________");
    _dump(event.payload.dataItem);
    log(this.info);
    log("____________________________________________");
    log("____________________________________________");
    var m = 88;
    KONtx.application.loadview('view-Sub2', { foo: this.info }); //you could also pass as { foo: event.payload.dataItem };
    }
    }
    });
    },
    imageUpdater: function(cell,data){
    cell.info = data; //data bound as an expando property;
    }


    Also, if you're not receiving the data in the next view as you'd expected, make sure that you're accessing it properly.

    Hope that helps.

    - Ben
    0
  • hey!! thanks.. now i have variable value on next screen. thanks.
    0

Recent Posts

in Design / Interaction - Yahoo! TV Widgets