Getting toolbar list options in same order as they are displ

I am building options for a drop down menu on a toolbar from a database table, giving the id’s for the options the same value as the index in the table, however ordered alphabetically by the description of the option. The visual drop down comes out sorted nicely, however when I ask for a list of all options, they are sorted by id, i.e. getAllListOptions() and forEachListOption(). Are there ways to lookup the option list in the “right” order to pick say the first option in the list, other than sorting the list again myself?

To clarify I am using 4.1.2 proffesional.

Options are sorted alphabetically from the database, the problem is dhtmlx seem internally to order options by ID, i.e. if I call getAllListOptions(), the first option in the list returned is not the first visible option in the drop-down (which is the first alphabetically by description), but the one with the lowest ID. There is a mismatch between the internal and the visual representation. I.E. when I call getAllListOptions(), I expect to get a list in the same order as the options are ordered visually in the drop-down, not ordered by ID. At this point it seem impossible for me to get the first option in the list, since I get an inaccurate result back from dhtmlx. I could number the options incrementally, however then I would get a disconnect between the option picked and the database index.

After scouring through the javascript source code for the dhtmlx toolbar, I constructed a solution that seem to do what I want. Apparently there are no functions that expose the visual options, so only way to access is through attributes on the object.

In case others run into the same issue, here is what I did:

//Get all visible options var asList = this.objPull[this.idPrefix + "tbb" + sChart].p_tbody.childNodes; //If options exist for Chart set drop-down to first option in list if (asList.length > 0) { this.setListOptionSelected("tbb" + sChart, asList[0].idd); this.setItemText("tbb" + sChart,"<strong>{0}</strong>".format(this.GetSelectedItemText("tbb" + sChart))); }

Hi,

There is no built-in solution, unfortunately.
The method which you have created looks fine, and must not cause any issue.

We will check how it can be improved in the next update.