[ZBXNEXT-2185] jqueryui autocomplete dropdowns instead of ordinary selects Created: 2014 Mar 05  Updated: 2021 May 26  Resolved: 2021 May 26

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Frontend (F)
Affects Version/s: None
Fix Version/s: 5.0.11

Type: New Feature Request Priority: Major
Reporter: Jan Keirse Assignee: Unassigned
Resolution: Fixed Votes: 9
Labels: dropdown, jquery, patch, usability
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Zip Archive autocomplete.zip     Zip Archive autocomplete.zip     PNG File dropdown.png     PNG File minimumResultForSearch_10.png     GIF File select2-spinner.gif     PNG File select2.png     PNG File select2x2.png     PNG File wrappingwithandwithoutautocomplete.png     Text File zabbix-2.2.4-zbxnext-2185.patch     Text File zabbix-2.2.4-zbxnext-2185.patch     Text File zabbix-2.2.4-zbxnext-2185v3.patch     Text File zabbix-2.4.6-zbxnext-2185.patch     Text File zabbix-3.0-select2.patch    

 Description   

Hello,

we have a large number of screens and a large number of graphs per host (hundreds). Finding the appropriate screen or graph using the existing select widgets can be a pain.
Since jquery and jqueryui are already used by zabbix, I wonder if it would be a lot of work to change all drop downs in zabbix to use autocomplete as demonstrated by http://jqueryui.com/autocomplete/#combobox

Thanks for taking this into consideration,

Jan



 Comments   
Comment by Jan Keirse [ 2014 Apr 23 ]

A patch using select2 to implement this feature. I made tiny modifications to the select2 css file so that dropdown's are about the same height as they are without this patch.
http://ivaynberg.github.io/select2/

The patch is against 2.2.3 but a version that is also patched with zbx extras and the snmp builder, however only 3 zabbix files contain 1 or 2 extra lines, so it shouldn't really matter to apply it.

You also have to put these files in styles/ :

select2.png
select2-spinner.gif
select2x2.png

They can be found in this archive:
https://github.com/ivaynberg/select2/archive/3.4.6.tar.gz

Comment by Jan Keirse [ 2014 Apr 23 ]

Screenshot of the result.

ps.: The Attach Screenshot button redirects me to an oracle page hence the use of Attach Files.

Comment by Jan Keirse [ 2014 Apr 23 ]

It looks a little better if you add this to the bottom of select2.css:

 
.select2-container  {
    border: none;
}

.header_r .select2-container {
    margin-top: -3px;
}

.item-list-row .select2-container {
    margin-top: 6px;
}

.select2-result-label {
    line-height: 1.1em;
}

(2014-04-25 these fixes have been included in the patch currently attached to the issue)

Comment by Tatapoum [ 2014 Apr 24 ]

+1
That would be an easy and nice improvement to the frontend when dealing with a large number of items.

Comment by Jan Keirse [ 2014 Apr 24 ]

Thanks, but I think it's best to use the vote system on the right side of the issue in the people section, so that it turns up in queries for popular issues. Given the huge impact on usability on bigger installations (we have by now over 1000 graphs on some hosts) and the availability of a patch with almost no code changes to the actual zabbix code it looks to me like a nice candidate for addition to standard zabbix.

Comment by Jan Keirse [ 2014 Apr 25 ]

There's still a little issue, select2 also kicks in when selecting applications for a new item but that doesn't work particularly well. I'll see if how I can fix that.

Comment by Jan Keirse [ 2014 Apr 25 ]

Fix for this issue, but disabled for multiselect boxes as it didn't work for those and was not very usefull anyway.
Basically multiselect can be disabled from the constructor of ccombobox.

Comment by Jan Keirse [ 2014 Jun 30 ]

Patch against vanilla 2.2.4.

Comment by Jan Keirse [ 2014 Jun 30 ]

The version I have just added is a patch against 2.2.4 as part of the RPM. It shows how little has to change in the actual zabbix code.

Comment by Marc [ 2014 Jul 02 ]

Interesting idea!

Two things that possibly could be improved:

  • combo-box entries may wrap
  • in pop-ups selection isn't visible
Comment by Jan Keirse [ 2014 Jul 03 ]

Fixed style.css so that selected value in drop down is visible for popups.

Comment by Jan Keirse [ 2014 Jul 03 ]

Marc, what exactly do you mean with 'Combo-box entries may wrap'?
If I have a very long graph name it is shown in the drop-down selection list on 2 lines so that it's entirely readable but that's expected behavior, works fine and is probably not what you're hinting at.
I do notice that when you select such very long graph name, the widget is shown on a second line, but this behavior is the same without select2 as seen in the attached screenshots. I don't think it's necessarily bad either.

Comment by Jan Keirse [ 2014 Jul 03 ]

image that shows combo box moves to second line both with and without select2

Comment by Jan Keirse [ 2014 Jul 03 ]

patch including all modified code

Comment by Jan Keirse [ 2014 Jul 03 ]

Files to be stored in styles/ folder.

Comment by Volker Fröhlich [ 2014 Jul 03 ]

Works fine as far as I can tell, but it is also present in some places where I would rather not have it. It doesn't really make sense on dropdowns with fixed content, e. g. severity on Monitoring/Maps.

For whatever reason it appears to be missing for "Host" on the following Configuration/Hosts entities: Graphs, Web, Triggers, Applications. I applied the patch on a 2.2.0 though, so that may cause it.

Comment by Jan Keirse [ 2014 Jul 04 ]

Updated version of select2 to 3.5.0 and extracted custom css (specific for zabbix) from the original select2.css file into an additional one (select2-zabbix.css) to make it possible to upgrade without having to rebase the original select2 css file everytime.

Comment by Jan Keirse [ 2014 Jul 04 ]

Volker, disabling it for fixed content dropdowns could be done, I have updated the CComboBox class constructor with an option $autocomplete that defaults to true, but could be set false for small dropdowns (and must be set to false for the current multiselect comboboxes.) However I am undecided if should be disabled for small comboboxes, while the feature is not required there I think the interface looks cleaner if all comboboxes have the same styling.
I hadn't noticed the missing functionality on the Configuration/Hosts entities yet. I'll have a look if I can see what's going on there.

Comment by Jan Keirse [ 2014 Jul 04 ]

v3 version of the patch fixes the problem where the multiselect didn't work if there are multiple html elements with the same id (hostid) on the page.

Comment by Marc [ 2014 Jul 29 ]

Just played around with select2 again.
What about setting 'minimumResultForSearch' to a reasonable value (e.g. 10) to prevent auto-search for small combo-boxes?

Comment by Jan Keirse [ 2014 Jul 29 ]

I don't know, I prefer to have the same look for all combo-boxes. While the search isn't required for small comboboxes it doesn't hurt either and it looks a little sloppy if not all combo-boxes have the same look.

Comment by Marc [ 2014 Jul 29 ]

That's the point.
When using the mentioned setting the look keeps the same. Just the auto-search functionality (input field) is disabled, respectively hidden:

Comment by Jan Keirse [ 2014 Jul 29 ]

Aah, I agree. I thought you were suggesting to add an option to zabbix that would disable calling select2 for small combo-boxes. I see now that select2 has an option to just remove the search box which does make sense.

Comment by Marc [ 2014 Jul 29 ]

Btw, adding ~15 17 pixels to the element width in resolveContainerWidth() of select2.js seems to prevent cutting/wrapping of values.
Don't know whether there is a less hackish way to achieve the same.

Some combo-boxes get display:inline set what leads to combo-boxes with maximum width. E.g. on item edit.
To prevent this I changed 'inline' to 'inline-block' in CViewSwitcher class (for objDisplay its default case).

Another thing I chaged was the border-radius. Setting this to 0px looks a bit more similar to the origin combo-boxes.

Yet another thing I changed was left text aligning for current selection/chosen text.

The patch in connection with iexplore 9 makes no fun when having ~1.5k elements. It's very laggy - not that I care though...

Comment by Branislav Brna [ 2015 Apr 30 ]

Hi,
this is almost exactly what I am looking for. Will this work on 2.4.4? And if yes how do I install this - sorry I am new to zabbix so I have no idea how to do it.

Thanks in advance

Comment by Jan Keirse [ 2015 May 04 ]

Yes it will work, but it will need some changes. I have it running on a modified version of zabbix 2.4.3 (various patches applied.) I'll try to make an updated patch for the latest stable release within 2 weeks, if I can find the time.

Comment by Branislav Brna [ 2015 May 04 ]

Thank you for reply. That sound awesome. This sort of functionality is must for us since we frequently search graphs by name. I am looking forward for updated patch.

Thanks again

Comment by Branislav Brna [ 2015 May 25 ]

Hi.
anything new regarding the patch?

Comment by Jan Keirse [ 2015 May 26 ]

Sorry, I haven't found the time due to other projects I'm working on. I will eventually make a new patch (if nobody else does it) but it will take at least a few more weeks.
Maybe have a look at the patch file in a text editor, the contents of the zip file,... and it might already be obvious to you how to make the required changes.

Comment by Branislav Brna [ 2015 Aug 19 ]

Hi,
have you managed to look into it?

Comment by Jan Keirse [ 2015 Aug 19 ]

This should work, although I haven't tested it yet.

Installation procedure pretty much goes like this:
copy the files select2.png select2-spinner.gif select2x2.png to /usr/share/zabbix/styles
copy the .patch file to your home directory

And then:
cd /usr/share
tar cvzf ~/zabbix-backup.tar.gz zabbix
cd /usr/share/zabbix
patch -p3 < ~/zabbix-2.4.6-zbxnext-2185.patch

In case something goes wrong you should be able to recover with
cd /usr/share
tar xvzf ~/zabbix-backup.tar.gz

Comment by Branislav Brna [ 2015 Aug 25 ]

Hi,
thanks for patch, but unfortunately it is not working for me. Is there something else that needs to be done except procedure that you described?

Comment by Jan Keirse [ 2015 Aug 31 ]

No, could you try to see what the javascript console in your browser says?

Comment by Branislav Brna [ 2015 Aug 31 ]

I get no errors. Only these two warnings:
Use of Mutation Events is deprecated. Use MutationObserver instead. telify.js:962:0
Use of getPreventDefault() is deprecated. Use defaultPrevented instead. jsLoader.php:4979:0

Any idea where is the problem?

Comment by Jan Keirse [ 2015 Sep 08 ]

There's no telify.js in my installation, I have no idea where you got it, but I don't think it came from zabbix or my patch.

Comment by Branislav Brna [ 2015 Sep 08 ]

And is this patch working for you fine?

Comment by Jan Keirse [ 2015 Sep 08 ]

Yes. Have you looked in your server log files?

Comment by Branislav Brna [ 2015 Sep 08 ]

Ok so after setting up new test machine I can see it is working. I guess in my production machine/real test machine it is not working because I installed Zabbix-Extras which are somewhat broken in their own regards.
I cant even say how happy I am to get this working, because this was major hold back for us to start replacing Nagios + Cacti with Zabbix. Hope this gets integrated into core soon.

Comment by Ronny Pettersen [ 2017 Sep 20 ]

This would be a very nice additions to installations with larger number of hosts/groups. And also make selecting much easier.
Select2 is very good, and could even improve how it looks when you have nested groups:
https://www.sitepoint.com/13-jquery-selectboxdrop-down-plugins/

Select2 is now in version 4.0.3, so I would say it is very mature and should be safe to include as it supports most browsers.
https://github.com/select2/select2/releases

Comment by Jan Keirse [ 2017 Oct 06 ]

I just attached a patch that can be applied to 3.0.4, if ever you were to consider this.

Comment by Jan Keirse [ 2019 Aug 14 ]

For those interested: Because this does not get merged in the product and I no longer wanted to patch each release I have solved this problem in the browser instead: https://github.com/jankeirse/zabbix-select2-dropdowns 

Tested with zabbix 4.0.5. Advantage: far easier to deploy than patching the server. Should be largely version independent. Disadvantage: every zabbix user that wants it has to install it in the browser of their choice. 

 

Comment by Alexei Vladishev [ 2021 May 26 ]

I believe it is pretty much resolved in the latest 5.x. We introduced autocomplete controls (instead of long drop-downs) across all UI.

Generated at Wed Jul 16 10:20:05 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.