cancel
Showing results for 
Search instead for 
Did you mean: 

Creating submenus

croc
Champ in-the-making
Champ in-the-making
Hi,

How can I add a submenu to the submenu?
I need to add a new menu on Records search, and that menu has a submenu which also has a submenu.

E.g, Content>>Type>>select type.

When you mouse-over content it populates Types, and when you mouse-over Types, it gives you a document type.

I know I have to make changes on rm-property-menu.js file but I am not sure how to do that.

Thanks,
Croc
4 REPLIES 4

kevinr
Star Contributor
Star Contributor
We use the YUI menu control to generate our menus:
http://developer.yahoo.com/yui/menu/

So take a look a the example for creating sub-menus in there.

Thanks,

Kevin

croc
Champ in-the-making
Champ in-the-making
Thank you very much.

croc
Champ in-the-making
Champ in-the-making
Thanx again Kevin, it is working.

though I still have a problem.

The submenus works very well if I have hard-coded the values, but it gives me a problem when I want to populate them dynamically.
Below is the code:

var itemdata = aspectMenu.submenu.itemdata;
   

            for (var i=0, j=this.options.visible.length; i<j; i++){
               var prop = this.options.visible[i];
               var splitProp = prop.id.split(":");
      for (var k=0, m=this.options.formFields.length; k<m; k++){

             var formProp = this.options.formFields[k];
             var splitFormProp = formProp.id.split(":");
      
             if(splitProp[0] == splitFormProp[0]){
                itemdata.push(
                {
              text: $html(prop.title),
              submenu: { id: "applications",
               itemdata: [{text:$html(formProp.title), value:formProp.id}]
                }
                });
         }
            }
   }

I have two arrays, the first one is for the apects, and the second one is for the fields. Now I want to populate the aspect array with the fields array as the submenus.

I have two loops, the first one is for the aspects( for (var i=0, j=this.options.visible.length; i<j; i++){) and the second one is for the fields(for (var k=0, m=this.options.formFields.length; k<m; k++){).
The problem is that it prints aspects based on the number of fields it get on that aspect.
I have used this;    if(splitProp[0] == splitFormProp[0]){  to filter the aspects and fields, based on their prefixes as they use the same.
E.g, if aspect TEST1 has 5 fields, it prints each field on it's own TEST1

Thanks very much in advance.

Regards,
Croc

croc
Champ in-the-making
Champ in-the-making
HI Guys,
I have managed to get it working.


            var itemdata = aspectMenu.submenu.itemdata;
       var itemdataField = fieldsMenu.submenu.itemdata;
       itemdataField = []; //I had to clear this Arrays so it will store new data

   for (var i=0, j=this.options.visible.length; i<j; i++){

               var prop = this.options.visible[i];
               var splitProp = prop.id.split(":");

      itemdataField = [];
      for (var k=0, m=this.options.formFields.length; k<m; k++){ //this loop adds fields to the ItemdataField Array

             var formProp = this.options.formFields[k];
             var splitFormProp = formProp.id.split(":");
         
             if(splitProp[0] == splitFormProp[0]){

                itemdataField.push(

                {
            text:this.msg((formProp.title)),
            value:formProp.id

                });
         }


            }
                       //Then I push the values of that array to an aspect based on the i counter of the first loop.
         itemdata.push(

                {
            text:$html(prop.title),
            submenu: { id: "_field"+i,
                  itemdata: [itemdataField]
                }

                });

      }

Thanx
Croc