Search code examples
c#asp.net-mvcteleriktabindex

Setting a Tab Index for Telerik ComboBoxBuilder


So I've inherited an older project that uses Telerik, made by someone who no longer works with my company. Apparently, the syntax Telerik uses has changed, and I cannot find documentation on what the new, correct syntax is on setting a tabindex for a combobox anywhere on Telerik's site, nor the rest of the internet.

The code I have is as follows:

Html.Telerik().ComboBoxFor(model => model.Customer.AccountExecutive.SalesPersonCode)
                                        .Name("salesRepCombo")
                                        .Value(Model.Customer.AccountExecutive.SalesPersonCode)
                                        .HtmlAttributes(new { style = "width:200px" })
                                        .InputHtmlAttributes(new { tabindex = 5})
                                        .BindTo((IEnumerable<SelectListItem>)ViewData["SalesPeople"])
                                        .Filterable(filtering => filtering.FilterMode(AutoCompleteFilterMode.StartsWith))
                                        .AutoFill(true)
                                        .HighlightFirstMatch(true)

The problem I am encountering is "Telerik.Web.Mvc.UI.Fluent.ComboBoxBuilder does not contain a definition for 'InputHtmlAttributes'".

Lacking any source to tell me the correct method, I've already tried using "HtmlAttributes(new { tabindex = 5})" and "DropDownHtmlAttributes(new { tabindex = 5})" to see if they worked, but neither sets the tabindex.

Does anyone know the proper syntax to use to set the tabindex, or does anyone know where the official documentation that covers this topic is located??


Solution

  • According to this Fluent ComboBoxBuilder Documentation the syntax that you are using appears to be correct accepts an anonymous object (similar to the default ASP.NET MVC syntax) and it should support an InputHtmlAttributes method as well.

    My initial thought is that the issue could be that there is a versioning difference between the documented version on their site and the version currently being used on your project. According to the documentation, InputHtmlAttributes appears to be supported in Version 2012.2.611.235 (2012.2.611.235) and above.

    If you don't have access to said version, you might be in a scenario that would require a workaround. I suppose that you could use a bit of Javascript or jQuery to target the affected element and add the tabindex attribute to it. It would be a bit hacky, but it might resolve it. You might also try asking this on Telerik's Support Forums, which can often be helpful for issues like these.