我在我的应用程序中使用剑道组合框,我需要在组合框实际功能之外从组合框中获取记录的值和 ID...我在表中针对每个记录使用组合框下拉列表,因此我无法中继在 css ID 上获取组合框值...我已经设法到达所选记录的输入组合框,并且我通过对其应用背景颜色进行了此测试。我已经测试了 .val() ,它仅适用于输入文本框,但不适用于 kendo ComboBox...
非常感谢
输入
<td class="N_td">@Html.TextBox("Input_MarkingSchemeTitle_Element", null, new { id = @item.ElementID + "_EMST", @class = "ElementMarkingSchemeTitle k1-grid-input k-textbox_3 _MarkSchemeId_Input" }) </td>
组合框功能
$("._MarkSchemeId_Input").kendoComboBox({
minLength: 1,
filter: 'contains',
dataTextField: "Name",
dataValueField: "ID",
dataSource: {
type: "json",
serverFiltering: false,
transport: {
read: "/Qualification/GetAllMarkScheme_JSON"
},
},
change: function () {
alert("value " + this.value() + " " + this.text());
}
});
jQuery 函数
$("#ElementTable").on("click", ".k1-grid-confirm", function () {
$(this).closest('table').find("._MarkSchemeId_Input").css("background", "red");
var a1 = $(this).closest('table').find("._MarkSchemeId_Input").text(); // doesn't work
alert("a1 " + a1);
.....
最佳答案
看看剑道 demo ,它实际上准确地显示了您对什么感兴趣
var fabric = $("#fabric").data("kendoComboBox");
var select = $("#size").data("kendoComboBox");
$("#get").click(function() {
alert('Thank you! Your Choice is:\n\nFabric ID: ' + fabric.value() + ' and Size: ' + select.value());
});
您的示例中的值检索不起作用,因为您正在调用 html 元素而不是 Kendo 控件的方法。考虑这个example :
$("#combobox").kendoComboBox({
dataSource: [ "Apples", "Oranges" ]
});
var combobox = $("#combobox").data("kendoComboBox");
combobox.value("Oranges");
因此,根据您的情况,请执行以下操作:
$(this).closest('table').find("._MarkSchemeId_Input").data("kendoComboBox").text()
关于javascript - 使用 JQuery 从输入 kendo ComboBox 获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22780861/