Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by nikit on Aug 25, 2009 03:49
open dhtmlx forum
dhtmlxCombo - Adding multiple images per options from array

Hi,
I’m trying to extend the dhtmlxCombo to allow multiple images per option in drop down list from array.

INIT:
var z = new dhtmlXCombo("combo1Container","alfa2",255,'image');
z._addOption({'value':'1','text':'Text1','img_src':['img/i1.png','img/img2.png']});
z._addOption({'value':'2','text':'Text2','img_src':['img/i3.png','img/img4.png']});

I’ve changed the code in “dhtmlcombo_extra.js” ( render ) :
dhtmlXCombo_imageOption.prototype.render = function() {
    if (!this.content) {
        this.content = document.createElement("DIV");
        this.content._self = this;
        this.content.style.cssText = 'width:100%;overflow:hidden;' + this.css;
        var html = '';        
        if (this.img_src){
            for(im=0; im<this.img_src.length; im++){
                html += '<img style="float:left;" src="' + this.img_src[im] + '" />';
            }
        }
        html += '<div style="float:left">' + this.text + '</div>';
        this.content.innerHTML = html
    }
    ;
    return this.content
};

It works fine except the Selected item logic – I can’t find how to extend the visualization of the selected option to allow multiple images. Could you assist me in this issue?
Answer posted by Alex (support) on Aug 25, 2009 05:35

Hello, 

you should also modify _DrawHeaderImage and RedrawHeader methods to show two images.