简体   繁体   English

extjs multiselect组合框中的最后选择的值

[英]Last selected value in extjs multiselect combobox

How do we get only the last selected value in multiselect combobox and not all the selected values? 我们如何只获得multiselect组合框中的最后一个选定值,而不是所有选定值? For example if we select three values 1, 3 and 2, then I want to retrieve 2 as it was selected at last. 例如,如果我们选择三个值1、3和2,那么我想检索最后选择的2。

When you get the value of combo by using combo.value you will see an array that is in order how you selected the combo data from combo Box. 当您通过使用combo.value获得combo的值时,您将看到一个数组,该数组的顺序是您从combo Box中选择组合数据的方式。 This leads you get the last index of combo.value will be your required result. 这导致您获得combo.value的最后一个索引将是您所需的结果。

In below code I taken a combo values and displaying the last result. 在下面的代码中,我采用了一个组合值并显示了最后的结果。

var combo = this.up().down('combo');
                var CoboVal = combo.value;
                var CoboValLength = CoboVal.length;
                if(CoboValLength !== 0){
                    var CoboValData = CoboVal[CoboValLength-1];
                    alert(CoboValData);
                }

I created a fiddle for you please check. 我为您制作了一个小提琴 ,请检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM