javascript 如何在剑道多选控件中获取所选项目的数量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16245055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 03:52:57  来源:igfitidea点击:

How to get the count of selected items in Kendo Multi Select Control?

javascriptjquerytelerikkendo-uimulti-select

提问by Rodney

What is the best way to get the count of selected Items in the Kendo multi select control?

在 Kendo 多选控件中获取所选项目数的最佳方法是什么?

I've tried:

我试过了:

multiSelect.dataItems().count()

and

multiSelect.value().count()

and neither work? Any suggestions would be greatly appreciated.

既不工作?任何建议将不胜感激。

回答by Derick Bailey

using multiSelect.value()will give you an array of the selected items. You can then get the .lengthoff the array:

usingmultiSelect.value()将为您提供所选项目的数组。然后,您可以.length关闭阵列:


var count = multiSelect.value().length;

http://docs.kendoui.com/api/web/multiselect#methods-value

http://docs.kendoui.c​​om/api/web/multiselect#methods-value

and

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/length

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/length

回答by Anil Singh

It might help to others

它可能对其他人有帮助

var multiSelectItems = $('#MultiselectCollection').data('kendoMultiSelect');
var count = multiSelectItems .value().length;