I have a scenario in which the data that the dropdown has many letters, so my first action was setting the width of the dropdown to 250px.
After this, I realized that when the dropdown displays, appears a horizontal scrollbar on the browser.
So I try to change the position of the dropdown. I tried this code:
var data = [{name:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},{name:"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"},{name:"ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"}]; $("#combo").igCombo({ dataSource:data, textKey:"name", valueKey:"name", width:"200px", dropDownWidth:"350px", dropDownOpened: function (evt, ui) { var container = $(ui.list[0]); var containerWidth = $(container).width(); var comboWidth = $($($(ui.owner.element[0]).parent()).parent()).width(); var dropDownLeft = comboWidth - containerWidth; $(ui.list[0]).css("left",dropDownLeft); } });
But when the dropdown opens, move to the new position and then go back to the initial position. I prepared a sample on jsfiddle
I think I am missing something to preserve the position.
To understand what I want to achieve.
This is the dropdown when opens:
This is what I want to achieve:
Best Regards
Hello Omar,
No you are not missing anything. It is a "limitation" of the way the dropdown positioning is implemented in the combo.
Once the dropdown is opened the combo will periodically recalculate the top/left properties to account for changes in the page (such as scrolling).
The first of these recalculations overrides your change.
There is no easy workaround. This is a possible one although I do not suggest it as it is too much of a hack and will definitely look bad in IE/Edge.
I'd log a feature request at https://github.com/IgniteUI/ignite-ui/issues
to expose either an option/hook into an event to control the dropdown position.