This is a migrated thread and some comments may be shown as answers.
Combobox Multi column support
8 Answers 264 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mohammed
Top achievements
Rank 1
Mohammed asked on 21 Apr 2011, 08:56 AM
Hi,

Currenly Telerik Mvc Combobox doesn't support Multi-columns. Is there are any workarounds? and if Telerik will consider this feature in future release.

Thanks.

8 Answers, 1 is accepted

Sort by
0
Accepted
Casey
Top achievements
Rank 1
answered on 11 May 2011, 08:14 PM
I wanted to do something like this too as our users are familiar with a code/description paradigm.  

What I'm doing is really crude but I didn't want to monkey too much with replacing the SelectList functionality that the AutoComplete/DropDownList/ComboBox controls utilize.  I'm making each SelectListItem's DataTextField an html table as demonstrated below.  I'm also hooking-up to the onChange event so that I can set the input field value to the DataValueField instead of the mishmash that's otherwise displayed.

Not very efficient or elegant, more quick and dirty...

return new JsonResult {
                Data = new SelectList(
                    _da.GetData( )
                        .OrderBy( s => s.Code )
                        .Select( s => new {
                            s.Code,
                            Display = string.Format("<table><tr><td class='h-dropdown-code-column' style='width:25%;'>{0}</td><td class='h-dropdown-description-column' style='width:*;'>{1}</td></tr></table>", s.Code, s.Description)
                        } ), "Code", "Display" )
            };


function onComboChanged(e) {
    $("#Combo-input").val(e.value);
}
0
Mohammed
Top achievements
Rank 1
answered on 13 May 2011, 02:21 PM
Hi Casey,

Thanks for your response.

Do have an example of how to implement the combobox in front-end. As im getting "Cannot perform runtime binding on a null reference" error.

Thanks.
0
Casey
Top achievements
Rank 1
answered on 13 May 2011, 02:34 PM
Hi Mohammed,

Unfortunately, I don't have the exact example anymore.  I ran in to some issues with how the fields lined up with a different set of data so I pulled everything to get back to it later.  

One thing I did find after my initial post, however, was that without handling one of the combobox events, the dropdown would display the HTML (i.e., "<table><tr><d>stuff</td></tr></table>") as text instead of a table.  That was simple enough to work around (just do nothing in the event, I think it was OnDataBinding it needed), but it raised some concerns with me that maybe this wasn't the best approach.

Anyway, I don't believe that there was/is much difference in how the combo itself is currently configured in my code and how it was when I posted, so here it is with no guarantees.  If/when I get back to this and have something working, I'll post back with more details.  It's kind of shame this functionality doesn't exist out of the box as I'm converting a web app that's about 5 years old and it has the functionality :(

Here's the combo setup; the referenced events aren't doing anything relevant to the layout, just rebinding the grid that's also on the page based on the value the user selects (onComboChanged) and adding an additional parameter to the POST data (onComboDataBinding)
@(Html.Telerik().ComboBox()
.Name("Combo")
.DataBinding(binding => binding.Ajax().Select("ControllerMethod", "Controller"))
.DropDownHtmlAttributes(new { style = string.Format("width:{0}px", 550) })
.ClientEvents(events =>
{
    events.OnChange("onComboChanged");
    events.OnDataBinding("onComboDataBinding");
})
.Filterable(filtering => { filtering.FilterMode(AutoCompleteFilterMode.Contains); }).HighlightFirstMatch(true))


0
Mohammed
Top achievements
Rank 1
answered on 13 May 2011, 02:39 PM
Hi Casey,

Thanks for the reply.

Im currenlty doing exactly the same as you, Im converting a web app that uses this functionality :-).

Well, I'll investigate keeping trying.

Thanks.
0
Henry
Top achievements
Rank 1
answered on 30 Jun 2011, 03:55 AM
@(Html.Telerik().DropDownList()
        .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
        .DataBinding(binding => binding.Ajax().Select("_GetBuildSchemes", "Production"))
        .DropDownHtmlAttributes(new { style = "width:300px" })
        .Encode(false)
)

.Encode is needed.

0
John DeVight
Top achievements
Rank 1
answered on 08 Sep 2011, 02:37 AM
Hi Mohammed,

I'm not sure if you still need this capability.  I've recently implemented this for the DropDownList control.  I've posted sample code and a sample project at: http://www.telerik.com/community/forums/aspnet-mvc/combobox/multi-column-support.aspx

You can also download my telerik.extensions.js file at: http://telerikmvcextendedjs.codeplex.com as well as see some documentation on it at: http://telerikmvcextendedjs.codeplex.com/wikipage?title=DropDownList

I can apply the same functionality to the ComboBox control as well and will see if I can get that done soon.  I'll post another message when it is done.

Regards,

John DeVight
0
Chris
Top achievements
Rank 2
answered on 18 Feb 2012, 10:51 PM
John - in the link where you mention "you posted the code at"... seems like that points to this thread.

I'll be checking other links now, but thanks for putting it together!
0
Kurkula
Top achievements
Rank 1
answered on 06 Jan 2013, 01:18 AM
I tried multi column combobox but when I added filterabale() option, multi column table format goes away with auto complete. Could you please guide me on logic to show table/columns format even on filtering data.
 
Tags
ComboBox
Asked by
Mohammed
Top achievements
Rank 1
Answers by
Casey
Top achievements
Rank 1
Mohammed
Top achievements
Rank 1
Henry
Top achievements
Rank 1
John DeVight
Top achievements
Rank 1
Chris
Top achievements
Rank 2
Kurkula
Top achievements
Rank 1
Share this question
or