This is a migrated thread and some comments may be shown as answers.

[Solved] Customizing the MVC DropDown List

1 Answer 102 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
LarryJ
Top achievements
Rank 1
LarryJ asked on 03 Oct 2010, 06:21 PM
I have a need to add a static area and a link to the bottom of the drop down list, like so...

[ Product Name ]
 | Chai                  |
 | Coffee               |
 | Custom Link      |

Where the third item is a link and is always available at the bottom on the drop list.

I am using the CodePlex version of the controls and I have started to trace through to find the details, but I am new to the idea of extending these controls and any help to get a good understanding and some tips would be appreciated.

TIA,
Larry

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 05 Oct 2010, 09:28 AM
Hi LarryJ,

You can achieve your goal with a few tricks. First you need to wire OnLoad of the component and bind it, like so:
function onLoad(e) {
    $(this).data('tComboBox').fill();
}

Then you need to attach OnOpen event insert the 'li' item in the correct place:
function onOpen(e) {
            var combo = $(this).data('tComboBox');
            var $items = combo.dropDown.$items;
            var $staticItems = $items.parent().find('li.static');
            if ($staticItems.length == 0) {
                $('<li class="static"><a class="t-link" href="#">Static Area</a></li>')
                    .insertBefore($items[0])
                    .find('> .t-link')
                    .bind('click', $.proxy(staticLink, combo));                   
            }
        }

As you can notice I have bind the link to a javascript method called "staticLink". Here is the code of the method:
function staticLink(e) {
            e.preventDefault();
 
            var $items = this.dropDown.$items;
             
            this.dropDown.scrollTo($items[$items.length - 1]);
        }

For your convenience I have attached my test project.

All the best,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
LarryJ
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or