This is a migrated thread and some comments may be shown as answers.
Problem with a dropdownlist in Filterable.UI method
2 Answers 5 Views
This is a migrated thread and some comments may be shown as answers.
Rui
Top achievements
Rank 1
Rui asked on 19 Sep 2017, 04:37 PM

I have a grid

@(Html.Kendo().Grid<TaskViewModel>()
.Name("taskGrid")
.Deferred()

...

.Columns(columns =>
{
columns.Bound(e => e.CrmWorkflowStatusText).Title("WF Status").Filterable(x => x.UI("SomeFunction")
.Extra(false)
.Operators(k => k
  .ForString(str => str.Clear()
  .IsEqualTo("Is equal to")
  .IsNotEqualTo("Is not equal to")

)));
})

...

.DataSource(dataSource => dataSource

...

))

that has a dropdownlist to filter one of the columns

 

function SomeFunction(element) {

const checkBoxTemplate = '@(Html.Kendo().CheckBox().Name("#:Title#").HtmlAttributes(new { @class = "checkbox", onchange = "SomeOtherFunction(this)" }))';

element.kendoDropDownList({

dataSource: {

transport: {

read: "@Url.Action("SomeAction")"

}},

optionLabel: "Select Something",

dataTextField: "Title",

dataValueField: "Title",

open: adjustDropDownWidth,

template: "<span><label>" + checkBoxTemplate + "<span id='#= Title #'>#= Title #</span></label></span>"

});

}

My problem is setting the id of this dropdownlist. I tried

 name: "somename"

and

htmlAttributes: { id: "somename" }


hmtlAttributes does nothing and name: "somename" sets the data-role attribute to "somename"...

 <input title="Value" style="display: none;" type="text" data-role="test123" data-bind="value:filters[0].value">

Is there a way to fix this?

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 21 Sep 2017, 07:29 AM
Hello, Rui,

I can suggest adding the attribute to the element using jQuery:

function SomeFunction(element) {
const checkBoxTemplate = '@(Html.Kendo().CheckBox().Name("#:Title#").HtmlAttributes(new { @class = "checkbox", onchange = "SomeOtherFunction(this)" }))';
 
$(element).attr('id', "test123")
 
element.kendoDropDownList({
dataSource: {
transport: {
read: "@Url.Action("SomeAction")"
}},



I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Rui
Top achievements
Rank 1
answered on 21 Sep 2017, 07:41 AM

Hello.
It works. Great.

Tks.

Tags
Grid
Asked by
Rui
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Rui
Top achievements
Rank 1
Share this question
or