How to set data attribute for Multiselect dropdown li element

1 Answer 320 Views
MultiSelect
datta
Top achievements
Rank 1
datta asked on 18 Apr 2023, 03:19 PM

I would like to disable partly multiselect dropdown li elements on basis of specific condition. To achieve this I tried to set data attributes on li elements  and check that data while rendering these li elements and apply CSS to disable it. But neither I find any related data in data object returned by KendoMultiselect nor in documentation.

$(itemIdservicetypes).on('change', function (e) {
			// Here we can get the value of selected item
			var seletctedValueST = $(itemIdservicetypes).data("kendoDropDownList").text();
			var data = $(itemIdSIMultiSelect).data("kendoMultiSelect");

			data.ul.children().each(function () {
				if (seletctedValueST == $(this).data("ServiceType") {
					$(this).addClass("k-disabled");
				} else {
					$(this).removeClass("k-disabled");
				}
			})

		});
Appreciate your help.

 

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 21 Apr 2023, 07:53 AM

Hi, Datta,

You could use the itemTemplate to apply the data attribute to a span inside the `li` element. Then you can use the attribute to access the `li` itself.

Dojo

I've prepared a Dojo example with several comments describing the overall idea behind the logic:

https://dojo.telerik.com/@gdenchev/OVITUJIl 

Best Regards,
Georgi Denchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

datta
Top achievements
Rank 1
commented on 25 Apr 2023, 11:33 AM

Thank you so much Georgi.

Your solution serves the purpose. But now I need to disable dropdown "li" elements during initial rendering of dropdown options that means for default selection or value, "li" elements should be disabled.

Appreciate your help.

Georgi Denchev
Telerik team
commented on 27 Apr 2023, 12:13 PM

Hi, Datta,

You can use the dataBound event of the MultiSelect to disable the elements upon initialization.

Dojo

https://dojo.telerik.com/@gdenchev/amiWeHoc 

Best Regards,

Georgi

Tags
MultiSelect
Asked by
datta
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Share this question
or