Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Ersin Kaplan on Sep 08, 2009 02:43
open dhtmlx forum
setItemImage

Dear DHX Team,


We would like to use the DHTMLX Menu and set item images.
The problem is that the icons are not displaying properly although the path is correct. The icons are on the same plane.

code:
setItemImage("artikel_erstellen","new.gif","new.gif");

Thank you very much, I really appricate your assistants.



Regards,



Ersin Kaplan


Answer posted by Alex (support) on Sep 08, 2009 03:54

Hello,

please, check the sample in the menu package dhtmlxMenu/samples/04_items/08_images.html, possibly it'll help to solve the issue (on the website http://dhtmlx.com/docs/products/dhtmlxMenu/samples/04_items/08_images.html).

If the issue can not be resolved, please provide the complete demo. 

Answer posted by Ersin Kaplan on Sep 08, 2009 04:54
I've looked at it but
the problem is still there the icons are not displaying properly
Answer posted by Alex (support) on Sep 08, 2009 05:18
please provide the complete demo
Answer posted by Ersin Kaplan on Sep 08, 2009 05:50
function createHeadermenu ($variable,$attribute)
        {
            $array = array();
            $array['design'] = '  //ROOT
                         var '.$variable.' = dhxLayout.attachMenu();
                          '.$variable.'.setIconsPath("/imgs/");
                        '.$variable.'.addNewSibling(null, "logout", "<b >Logout</b>", false); // adding the first item to the menu, "nextToId" param is null
                        
                         '.$variable.'.addNewSibling(null, "artikel","'.$attribute['artikel'].'", false); // adding the first item to the menu, "nextToId" param is null
                        '.$variable.'.addNewSibling(null, "mainmanue","'.$attribute['hauptmenu'].'", false); // adding the first item to the menu, "nextToId" param is null
                       
                    
                        //Child
                        
                        '.$variable.'.addNewChild("artikel", 0, "artikel_erstellen","'.$attribute['artikel_erstellen'].'", false); // adding a new child item
                        '.$variable.'.setHotKey("artikel_erstellen", "Ctrl+N"); // setting a hotkey to a button
                        '.$variable.'.addNewSeparator("artikel"); // adding a separator  

                        '.$variable.'.addNewChild("artikel", 0, "artikel_bearbeiten","'.$attribute['artikel_bearbeiten'].'", false); // adding a new child item
                        '.$variable.'.setHotKey("artikel_bearbeiten", "Ctrl+u"); // setting a hotkey to a button
                        '.$variable.'.addNewSeparator("artikel"); // adding a separator  
                        
                        '.$variable.'.addNewChild("artikel", 0, "artikel_suchen","'.$attribute['artikel_suchen'].'", false); // adding a new child item
                        '.$variable.'.setHotKey("artikel_suchen", "Ctrl+z"); // setting a hotkey to a button
                        '.$variable.'.addNewSeparator("artikel"); // adding a separator  
                       
                        '.$variable.'.setItemImage("artikel_erstellen","/imgs/new.gif","/imgs/new.gif");
                        '.$variable.'.setItemImage("artikel_bearbeiten","/imgs/edit.gif","/imgs/new.gif");                    
                        '.$variable.'.setItemImage("artikel_suchen","/imgs/edit.gif","/imgs/new.gif");
                        
                    
                        
                        
                        '.$variable.'.attachEvent("onClick", function(id, zoneId, casState){
                                                                                    /*
                                                                                    alert("element "+id+" was clicked");
                                                                                    alert (document.cookie+"sahd");
                                                                                    var sess = document.cookie;
                                                                                    */
                                                                                    
                                                                                    switch(id)
                                                                                    {
                                                                                        case "logout":
                                                                                        {
                                                                                            var des = confirm("'.$attribute['logout_meldung'].'");
                                                                                            if(des == true)
                                                                                            {
                                                                                                document.getElementById("out").submit();
                                                                                                loadLoader();
                                                                                            }
                                                                                        }
                                                                                        break;
                                                                                        case "artikel_erstellen":
                                                                                        {                                                                                
                                                                                            document.getElementById("hiddenForm").submit();
                                                                                            loadLoader();
                                                                                        }
                                                                                        
                                                                                        break;
                                                                                        case "mainmanue":
                                                                                        {                                                                                
                                                                                            document.getElementById("main").submit();
                                                                                            loadLoader();
                                                                                        }
                                                                                        
                                                                                        break;
                                                                                        case "artikel_suchen":
                                                                                        {                                                                                
                                                                                            document.getElementById("artikel_suchen").submit();
                                                                                            loadLoader();
                                                                                        }
                                                                                        
                                                                                        break;
                                                                                        
                                                                                    }
                                                                                    
                                                                                    
                                                                                    
                                                                                    if (casState["ctrl"] == true) {
                                                                                    // ctrl key was pressed with click
                                                                                    } else {
                                                                                    // ctrl key was not pressed with click
                                                                                    }
                                                                                    // alt
                                                                                    if (casState["alt"] == true) {
                                                                                    // alt key was pressed with click
                                                                                    } else {
                                                                                    // alt key was not pressed with click
                                                                                    }
                                                                                    // shift
                                                                                    if (casState["shift"] == true) {
                                                                                    // shift key was pressed with click
                                                                                    } else {
                                                                                    // shift key was not pressed with click
                                                                                    }
                                                                                });    
        
                                                                            ';
                $array['div'] = '<form method="post" action="index.php" id="hiddenForm">
                                    <input type = "hidden" name = "ebene" value = "artikel_erstellen"/>
                                </form>
                                <form method="post" action="index.php" id="main">
                                    <input type = "hidden" name = "ebene" value = "hauptmenue"/>
                                </form>
                                
                                <form method="post" action="index.php" id="out">
                                    <input type = "hidden" name = "ebene" value = "logout"/>
                                </form>
                                <form method="post" action="index.php" id="artikel_suchen">
                                    <input type = "hidden" name = "ebene" value = "artikel_suchen"/>
                                </form>
                                ';
                return $array;
        }
Answer posted by Alex (support) on Sep 08, 2009 06:54

Which menu version do you use ? there were actually issue with setItemImage and addNewChild(addNewSibling) in some previous version. There can not be issue in the 2.5 version.

The possible reason for teh problem is incorrect path. Do you take intoconsideration the path that you have defined in the setIconsPath method ?

Possibly the correct image path is setItemImage("artikel_erstellen","new.gif","new.gif") instead of setItemImage("artikel_erstellen","/imgs/new.gif","/imgs/new.gif") ?

The provided snippet isn't complete demo. So, please if the issue still occurs, please provide the sample ( http://www.dhtmlx.com/docs/support/what_is_a_completed_demo.htm )

Answer posted by ersni kaplan on Sep 08, 2009 07:00
ah ok thanks