working on it ...

Filters

Explore Public Snippets

Sort by

Found 860 snippets matching: dropdown

    public by cghersi modified Jul 2, 2014  7471  1  7  2

    Java SWT: Combobox with AutoSuggestion feature

    This component can be safely used when you want to have a combobox with the capability to display automatic filtered suggestions based on the text already entered. It uses a couple of callback actions so that the caller can specify what to do when ENTER key is hit and how to load suggestions. The call back actions are specified by a simple interf
    package com.snip2code.ui.swt;
    
    import java.util.List;
    import java.util.Random;
    
    import org.apache.log4j.Logger;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.custom.StackLayout;
    import org.eclipse.swt.events.FocusAdapter;
    import org.eclipse.swt.events.FocusEvent;
    import org.eclipse.swt.events.KeyAdapter;
    import org.eclipse.swt.events.KeyEvent;
    import org.eclipse.swt.events.MouseAdapter;
    import org.eclipse.swt.events.MouseEvent;
    import org.eclipse.swt.events.SelectionAdapter;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.graphics.Rectangle;
    import org.eclipse.swt.layout.FillLayout;
    import org.eclipse.swt.layout.GridData;
    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.widgets.Composite;
    import org.eclipse.swt.widgets.Control;
    import org.eclipse.swt.widgets.Event;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.Listener;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Table;
    import org.eclipse.swt.widgets.TableItem;
    import org.eclipse.swt.widgets.Text;
    
    import com.snip2code.utils.Utils;
    
    
    /**
     * (c) 2011 snip2code inc.
     * This software is property of snip2code inc. Use or reproduction without permission is prohibited 
     *
     * This widget creates a textfield with an autosuggestion feature.
     * The list of suggestion is shown when the user clicks on the text field or starts typing in the text field
     */
    public class AutoSuggestionComposite extends Composite {
    
    	protected static Logger log = Logger.getLogger(AutoSuggestionComposite.class);
    	
    	private Composite textBoxStackPanel;
    	private StackLayout textboxLayout;
    	private Text textBox;
    	private Label tooltip;
    	private Shell popupShell;
    	private Table table;
    	private String tooltipMsg;
    
    	private ICallback<String, List<String>> loadSuggestionAction;
    	private ICallback<String, String> onEnterAction;
    	
    	private String text;
    	private int numOfDisplayedSuggestions;
    	
    	private static final String POPUPVISIB = "$$$POPUP_VISIB";
    	
    	private String uniqueID; //used to differentiate AutoSuggestion composites in the same dialog
    	private static Random rdn = new Random();
    	
    	/**
    	 * Create the dialog.
    	 * @param parent
    	 * @param style
    	 * @param tooltipMsg message to display when no input is entered
    	 * @param numOfDisplayedSuggestions masimum number of items suggested in the popup of suggestions
    	 * @param loadSuggestionAction callback to routine that loads the suggestions for autocomplete
    	 * @param onEnterAction callback when enter is pressed on the textbox
    	 */
    	public AutoSuggestionComposite(Composite parent, int style, String tooltipMsg, int numOfDisplayedSuggestions, 
    			ICallback<String, List<String>> loadSuggestionAction, ICallback<String, String> onEnterAction) {
    		super(parent, style);
    
    		textboxLayout = new StackLayout();
    		this.loadSuggestionAction = loadSuggestionAction;
    		this.onEnterAction = onEnterAction;
    		this.numOfDisplayedSuggestions = numOfDisplayedSuggestions;
    		this.tooltipMsg = tooltipMsg;
    		
    		uniqueID = rdn.nextInt() + tooltipMsg;
    		
    		createDialogArea();
    	}
    	
    	private void createDialogArea() {
    		this.setBackground(SWTUIUtilities.WHITE);
    		GridLayout gridLayout = new GridLayout();
    		gridLayout.marginHeight = 0;
    		gridLayout.marginWidth = 0;
    		this.setLayout(gridLayout);
    
    		//Panel with textbox and tooltip:
    		textBoxStackPanel = new Composite(this, SWT.NONE);
    		textBoxStackPanel.setLayout(textboxLayout);
    		GridData gdPanel = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    		gdPanel.verticalIndent = 2;
    		textBoxStackPanel.setLayoutData(gdPanel);
    		
    		tooltip = new Label(textBoxStackPanel, SWT.NONE);
    		tooltip.setBackground(SWTUIUtilities.WHITE);
    		tooltip.setForeground(SWTUIUtilities.LIGHT_GREY);
    		tooltip.setFont(SWTUIUtilities.LBL_TEXT);
    		tooltip.setText(" " + tooltipMsg); //manual horizontal indent, cause StackLayout doesn't allow this feature
    		tooltip.addMouseListener(new MouseAdapter() {
    			@Override
    			public void mouseDown(MouseEvent e) {
    				setControlVisib(textBox, true);
    				textBoxStackPanel.layout();
    				textBox.setFocus();
    				loadSuggestions(null);
    			}
    		});
    		
    		textBox = new Text(textBoxStackPanel, SWT.NONE);
    		textBox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    		textBox.setFont(SWTUIUtilities.LBL_TEXT);
    		textBox.setBackground(SWTUIUtilities.WHITE);
    		textBox.setData(POPUPVISIB, uniqueID);
    		
    		//popup for suggestions:
    		popupShell = new Shell(getShell().getDisplay(), SWT.ON_TOP);
    		popupShell.setLayout(new FillLayout());
    		popupShell.setData(POPUPVISIB, uniqueID);
    		popupShell.setBackground(SWTUIUtilities.WHITE);
    		table = new Table(popupShell, SWT.SINGLE);
        	table.getVerticalBar().setVisible(false);
    		table.setFont(SWTUIUtilities.LBL_TEXT);
    		table.setData(POPUPVISIB, uniqueID);
    		for (int i = 0; i < numOfDisplayedSuggestions; i++) {
    			new TableItem(table, SWT.NONE);
    		}
    		
    		//Key Listener for Keyboards events:
    		textBox.addKeyListener(new KeyAdapter() {
    			@Override
    			public void keyReleased(KeyEvent e) {
    				boolean loadSuggestions = true;
    				saveInput();
    				switch (e.keyCode) {
    					case SWT.ARROW_DOWN:
    						int index = (table.getSelectionIndex() + 1) % table.getItemCount();
    						table.setSelection(index);
    						e.doit = false;
    						break;
    					case SWT.ARROW_UP:
    						index = table.getSelectionIndex() - 1;
    						if (index < 0) 
    							index = table.getItemCount() - 1;
    						table.setSelection(index);
    						e.doit = false;
    						break;
    					case SWT.CR:
    					case SWT.LF:
    					case 16777296: //enter in numeric keypad
    						if (popupShell.isVisible() && table.getSelectionIndex() != -1) {
    							textBox.setText(table.getSelection()[0].getText());
    						}
    						
    						loadSuggestions = false;
    						execEnterAction();
    
    						break;
    					case SWT.ESC:
    						popupShell.setVisible(false);
    						break;
    				}
    
    				//only for printable characters, load search history:
    				if (loadSuggestions && (e.keyCode < 256))
    					loadSuggestions(textBox.getText());
    				
    				log.debug("End of key listener");
    			}
    		});
    		
    		//make sure the input entered in the text box is saved and ready to use:
    		textBox.addFocusListener(new FocusAdapter() {
    			@Override
    			public void focusLost(FocusEvent e) {
    				log.debug("Focus lost by textbox of autosugg from " + tooltipMsg);
    				saveInput();
    				checkTooltipVisib();
    				handleFocusLost();
    			}
    			
    			@Override
    			public void focusGained(FocusEvent e) {
    				if (isDisposed() || getShell().isDisposed() || getShell().getDisplay().isDisposed()) 
    					return;
    				log.debug("Focus gained by textbox of autosugg from " + tooltipMsg);
    				loadSuggestions(textBox.getText());
    			}
    		});
    		textBox.addSelectionListener(new SelectionAdapter() {
    			@Override
    			public void widgetSelected(SelectionEvent e) {
    				checkTooltipVisib();
    			}
    		});
    		
    		table.addListener(SWT.DefaultSelection, new Listener() {
    			public void handleEvent(Event event) {
    				textBox.setText(table.getSelection()[0].getText());
    				execEnterAction();
    			}
    		});
    		
    		//hide the popup of suggestions if the focus is out:
    		Listener focusOutListener = new Listener() {
    			public void handleEvent(Event event) {
    				handleFocusLost();
    			}
    		};
    		table.addListener(SWT.FocusOut, focusOutListener);
    		textBox.addListener(SWT.FocusOut, focusOutListener);
    		textBoxStackPanel.addListener(SWT.FocusOut, focusOutListener);
    		popupShell.addListener(SWT.FocusOut, focusOutListener);
    		this.addListener(SWT.FocusOut, focusOutListener);
    
    		getShell().addListener(SWT.Move, new Listener() {
    			public void handleEvent(Event event) {
    				popupShell.setVisible(false);
    				checkTooltipVisib();
    			}
    		});
    		
    		checkTooltipVisib();
    	}
    	
    	private void handleFocusLost() {
    		/* async is needed to wait until focus reaches its new Control */
    		if (isDisposed() || getShell().isDisposed() || getShell().getDisplay().isDisposed()) 
    			return;
    		getShell().getDisplay().asyncExec(new Runnable() {
    			public void run() {
    				log.debug("Running handleFocusLost for " + tooltipMsg);
    				if (isDisposed() || getShell().isDisposed() || getShell().getDisplay().isDisposed()) 
    					return;
    				Control control = getShell().getDisplay().getFocusControl();
    				log.debug("handleFocusLost for " + tooltipMsg + ": control is " + control + ";uniqueID:" + uniqueID);
    				if ((control == null) || (control.getData(POPUPVISIB) == null) || 
    					!control.getData(POPUPVISIB).toString().equals(uniqueID)) {
    					popupShell.setVisible(false);
    				}					
    			}
    		});
    	}
    	
    	/**
    	 * Determines the visibility of textbox content vs tooltip when the textbox is empty
    	 */
    	public void checkTooltipVisib() {
    		if (Utils.isNullOrEmpty(textBox.getText())) 
    			setControlVisib(tooltip, true);
    		else
    			setControlVisib(textBox, true);
    		textBoxStackPanel.layout();
    	}
    	
    	private void execEnterAction() {
    		saveInput();
    		popupShell.setVisible(false);
    		onEnterAction.exec(text);
    	}
    	
        private void loadSuggestions(String prefix) {
        	log.debug("loading suggestions for " + prefix);
    
    //		if (Utils.isNullOrEmpty(prefix))
    //			return;
        	
        	Rectangle textBounds = getShell().getDisplay().map(textBoxStackPanel, null, textBox.getBounds());
        	
    		//load suggestions:
        	List<String> suggestions = loadSuggestionAction.exec(prefix);
        	log.debug("loaded " + suggestions.size() + " suggestions");
        	
        	table.setItemCount(suggestions.size());
    		TableItem[] items = table.getItems();
    		int maxWidthOfItem = 0;
    		log.debug("Changing " + items.length + " items in TablePopup");
    		for (int i = 0; i < items.length; i++) {
    			if (i < suggestions.size()) {
    				String sugg = suggestions.get(i);
    				if (!Utils.isNullOrEmpty(sugg)) {
    					items[i].setText(sugg);
    					int w = items[i].getBounds().width;
    					if (w > maxWidthOfItem)
    						maxWidthOfItem = w;
    				}
    			}
    		}
    //		//avoid the display of horizontal scrollbar when not needed (10 is the width of the scrollbar)
    //		if ((maxWidthOfItem + 10) < textBounds.width)
    //			table.pack();
    		
    		//23 pixels is the height of 1 item in the drop down list; 
    		//always add a blank line at the end of the list to improve readability
    		int popupHeight = (suggestions.size() + 1) * 23; 
    		log.debug("popupHeight for [" + this.tooltipMsg + "]:" + popupHeight);
    		if (popupHeight <= 46)
    			popupHeight = 46; 
    	
    		//set a cap to the maximum height of the popup (17 lines):
    		if (popupHeight > 391) {
    			popupHeight = 391;
    			table.getVerticalBar().setVisible(true);
    		} else {
    			//avoid the display of horizontal scrollbar when not needed (10 is the width of the scrollbar)
    			if ((maxWidthOfItem + 10) < textBounds.width)
    				table.pack();
    			table.getVerticalBar().setVisible(false);
    		}
    		
    		log.debug("setBounds popup:" + textBounds.x + ";" + (textBounds.y + textBounds.height + 4) + ";" + 
    					textBounds.width + ";" + popupHeight);
    		popupShell.setBounds(textBounds.x, textBounds.y + textBounds.height + 4, textBounds.width, popupHeight);
    		popupShell.setVisible(true);		
        }
        
    	private void setControlVisib(Control c, boolean visible) {
    		if (c == null)
    			return;
    		
    		if (visible) 
    			textboxLayout.topControl = c;
    	}
    	
    	private void saveInput() {
    		text = textBox.getText();
    		if (text == null)
    			text = "";
    		text = text.trim();
    	}
    	
    	/**
    	 * Returns the content of the textbox
    	 */
    	public String getText() {
    		return text;
    	}
    	
    	/**
    	 * Sets the content of the textbox
    	 */
    	public void setText(String text) {
    		this.text = text;
    		textBox.setText(text);
    		setControlVisib(textBox, true);
    	}
    	
    	/**
    	 * Hides the popup of suggestions
    	 */
    	public void hideSuggestions() {
    		popupShell.setVisible(false);
    	}
    	
    	@Override
    	public void dispose() {
    		if (popupShell != null) {
    			hideSuggestions();
    			popupShell.dispose();
    		}
    
    		super.dispose();
    	}
    }

    public by likwid modified Nov 4, 2014  1490  0  4  0

    DropDown

    DropDown: gistfile1.js
    var customerData = [
        {
            customerId: 1000,
            name: "ABC Company",
            postalCode: 75023 
        }, {
            customerId: 1001,
            name: "XYZ Company",
            postalCode: 75023
        }],
        pageData = [{
            pageId: 2000,
            title: "Page A",
            url: "/page=a"
        }, {
            pageId: 2001,
            title: "Page A",
            url: "/page=a"
        }];
    
    //Generic
    function formatForDropDown(id, descriptor, item) {
        return _.merge({}, { id: item[id], descriptor: item[descriptor] });
    }
    
    //Generic
    function selectFields(id, descriptor) {
        return _.partial(formatForDropDown, id, descriptor);
    }
    
    var pageItems = _.map(pageData, selectFields("pageId", "title")),
        customerItems = _.map(customerData, selectFields("customerId", "name"));
    
    console.log(_.first(customerItems));
    console.log(_.first(pageItems));
    
    

    public by lbottaro modified Nov 19, 2013  3954  8  7  0

    How to bind a validation list to a cell of Excel file in Csharp

    This c# method allows to define a validation list of entries (as string, using comma [,] as separator character) to bind to a specific cell for a sheet in an xls file (Microsoft Excel compatible). The validation list appears as a dropdown menu, where the user can choose the content from.
    enum Result
    {
        Passed,
        Partially_Passed,
        Failed,
        Blocked,
        Not_Applicable,
        Not_Tested
    }
    
    /// <summary>
    /// This method creates a Excel validation list for the selected cell, and associate the list to the cell (dropdown combo box)
    /// </summary>
    /// <param name="ws">Excel worksheet</param>
    /// <param name="excel_CellToValidate">Cell to validate</param>
    /// <param name="listForValidation">List of data to use for validation</param>
    private void Excel_createCellValidationDropDownList(Worksheet ws, string excel_CellToValidate, string listForValidation)
    {
    	ws.get_Range(excel_CellToValidate, excel_CellToValidate).Cells.Validation.Delete();
    	ws.get_Range(excel_CellToValidate, excel_CellToValidate).Cells.Validation.Add(
    		XlDVType.xlValidateList, XlDVAlertStyle.xlValidAlertInformation, XlFormatConditionOperator.xlBetween,
    		listForValidation, Type.Missing);
    }
    
    //Example of usage
    string m_excelList = string.Join(",", Enum.GetNames(typeof(Result)));
    this.Excel_createCellValidationDropDownList(ws, "C1", m_excelList);

    external by corpsefilth modified Apr 16, 2015  57  0  1  0

    Configurable products, make first dropdown option selected by default -- does not work with configurable swatches, only default configurable dropdown.

    Configurable products, make first dropdown option selected by default -- does not work with configurable swatches, only default configurable dropdown.: dropdownSelect.php
    <script>
    //we create new function
     
    spConfig.setInitialState = function(dropdown_id) {
     
    	//select dropdown
    	 
    	var dropdown = $(dropdown_id);
    	//remove empty option from dropdown so it is not selectable after initial selection
    	 
    	dropdown[0].remove();
    	//change selections in dropdowns
    	for(index = 0; index < dropdown.length; index++) {
    	 
    		if(dropdown[index].value != "") {
    		
    			dropdown.selectedIndex = index;
    			 
    			var element = dropdown;
    			var event = 'change';
    			 
    			//fire events
    			if(document.createEventObject) {
    			 
    				var evt = document.createEventObject();
    				return element.fireEvent('on'+event,evt);
    				
    			} else {
    			 
    				var evt = document.createEvent("HTMLEvents");
    				evt.initEvent(event, true, true );
    				return !element.dispatchEvent(evt);
    				
    			}
    		}
    	}
     
    };
     
    <?php foreach($_attributes as $_attribute): ?>
    spConfig.setInitialState("attribute<?php echo $_attribute->getAttributeId() ?>")
    <?php endforeach; ?>
    </script>
    
    

    external by Den McHenry modified Jun 5, 2016  22  0  1  0

    On certain browsers on Android devices, the country and state dropdowns for express checkout on Bigcommerce can't be selected. This is a Band-Aid to allow those users to make purchases till the real problem is solved. It simply replaces the dropdown wi...

    On certain browsers on Android devices, the country and state dropdowns for express checkout on Bigcommerce can't be selected. This is a Band-Aid to allow those users to make purchases till the real problem is solved. It simply replaces the dropdown with a plain text input in both the billing and shipping sections.: bc-state-dropdown-fix
    /* Temporary fix for BigCommerce express checkout issue re: state dropdown menu */
    
    $(document).ajaxComplete(function() {
      if ($('#uniform-FormField_12').hasClass('selector')) {
        $('#uniform-FormField_12').
            removeClass('selector').
            empty().
            append('<input type="text" name="FormField[2][12]" id="FormField_12" aria-required="1" class="FormField JSHidden Field200 field-xlarge Textbox"></input>');
      }
      
      if ($('#uniform-FormField_22').hasClass('selector')) {
        $('#uniform-FormField_22').
            removeClass('selector').
            empty().
            append('<input type="text" name="FormField[3][22]" id="FormField_22" aria-required="1" class="FormField JSHidden Field200 field-xlarge Textbox"></input>');
      }
    });
    
    
    
    
    

    external by Christopher Lamm modified Jun 25, 2013  410  5  3  0

    Creates a Bootstrap collapsible navbar with dropdowns. Navigation is populated by pages in the "Primary Navigation" menu. The dropdown items are child pages of the pages in the menu.

    Creates a Bootstrap collapsible navbar with dropdowns. Navigation is populated by pages in the "Primary Navigation" menu. The dropdown items are child pages of the pages in the menu.: bootstrap-wordpress-navigation.php
    PHP
    <?php
    
    /** @var array $menu_items Array of all post items part of the Primary Navigation menu. */
    $menu_items = wp_get_nav_menu_items( 'Primary Navigation' );
    
    ?>
    
    <nav id="primary-nav" role="navigation">
      	<div class="navbar navbar-static-top">
    			<div class="navbar-inner title-block-gradient">
    				<div class="container">
    					<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
    						<span class="icon-bar"></span>
    						<span class="icon-bar"></span>
    						<span class="icon-bar"></span>
    					</a>
    					<a class="brand" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?> - Home"><img src="<?php header_image(); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?> - Home" /></a>
    					<div class="nav-collapse collapse">
    						<ul class="nav pull-right">
    
    							<?php if ( $menu_items ) : ?>
    								<?php foreach ( $menu_items as $item ) : ?>
    									<li class="dropdown">
    										<a href="#" class="dropdown-toggle" data-toggle="dropdown" title="<?php echo $item->title; ?>"><?php echo $item->title; ?><b class="caret"></b></a>
    										<ul class="dropdown-menu">
    											<?php
    
    											wp_list_pages( array(
    												'sort_column' => 'menu_order',
    												'depth' => 1,
    												'child_of' => $item->object_id,
    												'title_li' => '',
    												'post_type' => 'page',
    												'post_status' => 'publish'
    											) );
    
    											?>
    										</ul>
    									</li>
    								<?php endforeach; ?>
    							<?php endif; ?>
    
    						</ul>
    					</div>
    				</div>
    			</div>
    		</div>
    	</nav>
    
    

    external by Dan Morain modified Oct 28, 2015  205  0  3  0

    Bootstrap Dropdown

    Bootstrap Dropdown: dropdown.html
    <div class="dropdown">
      <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
        Missions
        <span class="caret"></span>
      </button>
      <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
        
        <!-- clicking on Missouri St. Louis takes me to the Mission action method and passes the name parameter -->
        
        <li><a href="Mission?name=Missouri">Missouri St. Louis</a></li>
        <li><a href="#">Iowa Des Moines</a></li>
        <li><a href="#">California San Jose</a></li>
      </ul>
    </div>
    
    
    

    external by gaborsomogyi modified Nov 3, 2015  387  0  3  0

    modified dropdown editor for ag-grid to create multiple dropdowns in a grid; depends on lodash

    modified dropdown editor for ag-grid to create multiple dropdowns in a grid; depends on lodash: agDropDownEditor.js
     function agDropDownEditor(params, optionsName, optionsList) {
    
    		_.set(params.$scope, optionsName+'.optionsList', optionsList);
    		
            var html = '<span style="width:100%; display:inline-block" ng-show="!'+optionsName+'.editing" ng-click="'+optionsName+'.startEditing()">{{data.'+params.colDef.field+'}}</span> ' +
                '<select style="width:100%" ng-blur="'+optionsName+'.editing=false" ng-change="'+optionsName+'.editing=false" ng-show="'+optionsName+'.editing" ng-options="item for item in '+optionsName+'.optionsList" ng-model="data.'+params.colDef.field+'">';
    
            // we could return the html as a string, however we want to add a 'onfocus' listener, which is not possible in AngularJS
            var domElement = document.createElement("span");
            domElement.innerHTML = html;
    
            _.set(params.$scope, optionsName+'.startEditing', function() {
                _.set(params.$scope, optionsName+'.editing', true); // set to true, to show dropdown
    
                // put this into $timeout, so it happens AFTER the digest cycle,
                // otherwise the item we are trying to focus is not visible
                $timeout(function () {
                    var select = domElement.querySelector('select');
                    select.focus();
                }, 0);
            });
    
            return domElement;
        }
    
    

    external by StephanieMak modified Sep 17, 2015  196  0  2  0

    This is an example of using the JavaScript .dropdown("toggle") method in Bootstrap Because Bootstrap doesn't clear the "open" class on the dropdown parent, it stays open.

    This is an example of using the JavaScript .dropdown("toggle") method in Bootstrap Because Bootstrap doesn't clear the "open" class on the dropdown parent, it stays open.: gistfile1.html
    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
        <title>Test dropdown toggle</title>
        <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
        <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css">
      </head>
      <body>
        <div class="dropdown">
          <a class="dropdown-toggle" id="dropdownMenu1" href="#">Dropdown trigger</a>
          <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
            <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
            <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
            <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
            <li role="presentation" class="divider"></li>
            <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
          </ul>
        </div>
        <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
        <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.js"></script>
        <script>
          $(document).ready(function() {
              $("a.dropdown-toggle").click(function(ev) {
                  $("a.dropdown-toggle").dropdown("toggle");
                  return false;
              });
              $("ul.dropdown-menu a").click(function(ev) {
                  $("a.dropdown-toggle").dropdown("toggle");
                  return false;
              });
          });
        </script>
      </body>
    </html>
    
    
    

    external by kshyju modified Feb 26, 2014  159  0  2  0

    Get a list of custom types and map to a list of SelectListItems so that we can use that for MVC Viewmodel dropdown,

    Get a list of custom types and map to a list of SelectListItems so that we can use that for MVC Viewmodel dropdown,: CustomCollectionToSelectList
    public List<SelectListItem> GetActionTypes()
    {
        List<SelectListItem> actionTypesList = new List<SelectListItem>();
        actionTypesList = db.ActionTypes
                        .Select(s => new SelectListItem { Value = s.ID.ToString(), Text = s.Name }).ToList() ;
        return actionTypesList;
    }
    
    
    • Public Snippets
    • Channels Snippets