jQWidgets Forums

jQuery UI Widgets Forums General Discussions How to inherit jqxwidget?

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  chayk 12 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • How to inherit jqxwidget? #18580

    chayk
    Member

    Hi,

    How can I inherit the jqxwidget object?

    Basically what I want to do is

    var mydropdown = new DropDownList('#my-element', {checkboxes:true});
    mydropdown.addItem('addItem', 'jQuery')

    so DropDownList is inherited from jqxDropDownList and it has some default options which is different from original defaults of jqxDropDownList. When it is instantiate, I want to pass option parameter as an object that specifies option values different from DropDownList’s default value. Once it is instantiated, I want to use jqxDropDownList method with it.

    Here is what I tried but didn’t work.

    function DropDownList(id, uoptions) {
    this.id = id;
    // default options
    this.options = {
    checkboxes: true,
    displayMember: "Id",
    valueMember: "Id",
    width: 250,
    height: 25,
    theme: 'metro'
    };
    // init
    this.init.apply(this, arguments);
    // return
    return this.dropDownList;
    }
    DropDownList.prototype = {
    id: null,
    options:null,
    dropDownList:null,
    init: function(id, uoptions) {
    $.extend(this.options, uoptions);
    this.dropDownList = new $(id).jqxDropDownList(this.options);
    }
    }
    var mydropdown = new DropDownList('#pmis-columns', {checkboxes:false});
    mydropdown.addItem('addItem', 'jQuery'); // not work

    I want to achieve this in order to make many of same widgets that has my default options but also slightly different options from default. I can do just use jqxDropDownList and specify the options every time but it seems to me this is better solution.

    Thank you!

    How to inherit jqxwidget? #18589

    Peter Stoev
    Keymaster

    Hi chayk,

    Here is something simple as an alternative:

                    // Create a jqxComboBox
    $("#combobox").jqxComboBox({ selectedIndex: 0, source: dataAdapter, displayMember: "ContactName", valueMember: "CompanyName", width: 200, height: 25, theme: theme });
                   // get the comboBox's instance.
    var combobox = $("#combobox").data('jqxWidget');
    // set property.
    combobox.set({ selectedIndex: 10 });
    // get property.
    var selectedIndex = combobox.get('selectedIndex');
    // invoke method.
    combobox.open();

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    How to inherit jqxwidget? #18685

    chayk
    Member

    Thanks, Peter.

    var combobox = $("#combobox").data('jqxWidget');

    This part is what I need.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.