jQWidgets Forums
jQuery UI Widgets › Forums › General Discussions › How to inherit jqxwidget?
Tagged: inheritance
This topic contains 2 replies, has 2 voices, and was last updated by chayk 12 years, 2 months ago.
-
Author
-
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!
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 StoevjQWidgets Team
http://www.jqwidgets.comThanks, Peter.
var combobox = $("#combobox").data('jqxWidget');
This part is what I need.
-
AuthorPosts
You must be logged in to reply to this topic.