3

I am working on web application using kendo UI and I need to add a custom attribute to combobox.

How can I do this?

Nic
  • 12,220
  • 20
  • 77
  • 105
user2176191
  • 49
  • 1
  • 10

1 Answers1

5

You can use JQuery to set an attribute:

Example:

<input id="combobox" style="width: 100%"/>

$("#combobox").kendoComboBox({
    dataTextField: "text",
    dataValueField: "value",
    filter: "startswith",
    dataSource: data,
    dataBound: onDataBound
});

function onDataBound(e) {
    $("#combobox").closest(".k-combobox").attr("someAttr", "someValue");
};

This will result in:

Attr

Nic
  • 12,220
  • 20
  • 77
  • 105
  • is that a right way? OR do we have any other way like below. { field: "ColumnName", title: "Column Name", attributes: { class: "col-md-9 col-lg-9" }, headerAttributes: { class: "col-md-9 col-lg-9" } – user2176191 Jun 25 '15 at 04:38
  • That'd be for a Kendo Grid I guess. As far as I know the Combobox doesn't have those, unless you're using Kendo MVC, then you can use `HtmlAttributes()`. – Nic Jun 25 '15 at 04:52