0

Accessing the OptionSelectView of a SelectButton

Hey all.

I am trying to create a control of the KONtx.control.SelectButton variety. This control will be used to pick a user's birth year and, as such, it will have a lot of options. Because I am expecting the majority of my users to be selecting their birth year from the 3rd or 4th page, I would like the attached OptionSelectView to begin on page 3. After digging through framework code, I found the OSV class uses the Grid control for it's interface and I'm fairly sure that I will need to affect that part to reach my desired end. However I cannot figure out how to access the OSV instance.

If anyone has any hints for accessing the OptionSelectView associated with a SelectButton or with setting the OSV to a specific page, I'd appreciate

by
2 Replies
  • QUOTE (_buddy @ Jul 18 2011, 01:04 PM) <{POST_SNAPBACK}>
    Hey all.

    I am trying to create a control of the KONtx.control.SelectButton variety. This control will be used to pick a user's birth year and, as such, it will have a lot of options. Because I am expecting the majority of my users to be selecting their birth year from the 3rd or 4th page, I would like the attached OptionSelectView to begin on page 3. After digging through framework code, I found the OSV class uses the Grid control for it's interface and I'm fairly sure that I will need to affect that part to reach my desired end. However I cannot figure out how to access the OSV instance.

    If anyone has any hints for accessing the OptionSelectView associated with a SelectButton or with setting the OSV to a specific page, I'd appreciate


    Probably, you can try extending KONtx.system.OptionSelectView, and override the updateView method to add the code for changing the page. Then you can pass your new class as one of the inputs to the SelectButton control:

    new KONtx.control.SelectButton({optionViewClass:MyOptionViewClass});

    Let me know how it goes.

    Thanks,
    Vivek
    0
  • Damn...I don't know why I didn't think of this. Of course, it worked perfectly with a minimal amount of effort. Thanks for the nudge in the right direction!

    If anyone else is interested, here's the rather simple code for my class. Most of the code comes from the controls.input.js file from the framework

    CODE
    //Extending the OSV class to allow me to jump to a static page
    var YearSelector = new KONtx.Class({
    ClassName: 'YearSelector',

    Extends: KONtx.system.OptionSelectView,

    updateView: function () {
    KONtx_automation_log("function","KONtx.system.OptionSelectView","updateView");
    this.log(':: updateView');
    this.registerHandlers();
    this.controls.grid.changeDataset(this.config.data.options);
    //The following is the only additional line. It forces the grid to jump to the requested (0 indexed) page
    this.controls.grid.changePage(2, {refresh:true});
    },

    });


    Don't forget to include the js in your init file or before your view's createView definition!

    QUOTE (Vivek Jani @ Jul 20 2011, 07:11 AM) <{POST_SNAPBACK}>
    Probably, you can try extending KONtx.system.OptionSelectView, and override the updateView method to add the code for changing the page. Then you can pass your new class as one of the inputs to the SelectButton control:

    new KONtx.control.SelectButton({optionViewClass:MyOptionViewClass});

    Let me know how it goes.

    Thanks,
    Vivek
    0

Recent Posts

in General - Yahoo! TV Widgets