jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Get default html of jqxComboBox
This topic contains 4 replies, has 2 voices, and was last updated by Todor 5 years, 12 months ago.
-
Author
-
Hi!
I know I can customize the render function, but is there a way to get what the default html would have been? So this way I can simply add my stuff (especially since it’s such a small attribute add). Right now if I don’t use the custom renderer, I get some nice display but I need to add one attribute to the span. When I try to make something custom and keep the same style I fail to do so and I feel like copying over the styles isn’t such a nice idea maybe.
`var comboBoxRenderer = function (index, label, value) { // HERE Can I get default html here?
var html = “<span class=\”jqx-listitem-state-normal jqx-listitem-state-normal-bluefin jqx-item jqx-item-bluefin jqx-rc-all jqx-rc-all-bluefin\” automation-id=\”” + “WLPCombo” + editor[0].getAttribute(“id”) + “_” + index + “\”>” + value + “</span>”
console.log(html);
return html;
}editor.jqxComboBox({
autoDropDownHeight: true,
displayMember: ‘label’,
dropDownHorizontalAlignment: ‘center’,
height: height,
itemHeight: height,
placeHolder: null,
source: jqxComboBoxSource,
theme: CommonConstants.THEME,
renderer: comboBoxRenderer,
valueMember: ‘data’,
width: width,
// width for the dropdownlist, minimum of 150px when small cells and cell widths when larger
dropDownWidth: (width < 70) ? 70 : width,
// height for the dropdownlist, number of items up to a maximum of 5 items displayed
dropDownHeight: (cellLookupValues.length > 5) ? height * 5 : height * cellLookupValues.length
});`Thank you!
Hello epatpol,
You could select the span element by one of its classes, with jQuery for example, and then add an attribute to it.
renderer: function (index, label, value) { var $span = $('.jqx-item'); $span.attr('date-test', 'test'); }
Let us know if you need further assistance.
Best Regards,
TodorjQWidgets Team
https://www.jqwidgets.comHi Todor
That is indeed a good idea, however as soon as my custom renderer function with jquery in it is called, I get a list of “undefined” options in the dropdown. I think it overrides the default renderer (or I didn’t get the documentation right).
I don’t know if I explained my problem correctly, but thanks for the help so far!
Patrick
Also when I seem to do that it would affect all the span for all the cells in the grid. I need only the spans that are going to be rendered for that combobox, maybe there is a more unique selector I could use for JQuery?
Hello Patrick,
Please find the requested change in the following example.
Let us know if you need further assistance.
Best Regards,
TodorjQWidgets Team
https://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.