Javascript 使用JQuery从输入剑道组合框中获取值
我在我的应用程序中使用剑道组合框,我需要在组合框实际函数之外从组合框中获取记录的值和ID。。。。我在表中对每个记录使用comboBox下拉列表,所以我不能通过css ID来获取comboBox值。。。我已经成功地访问了所选记录的输入组合框,并通过对其应用背景色进行了此测试。我已经测试了.val(),它只适用于输入文本框,但不适用于剑道组合框 非常感谢 输入 jQuery函数 看一看剑道,它确实显示了你对什么感兴趣Javascript 使用JQuery从输入剑道组合框中获取值,javascript,jquery,kendo-ui,kendo-combobox,Javascript,Jquery,Kendo Ui,Kendo Combobox,我在我的应用程序中使用剑道组合框,我需要在组合框实际函数之外从组合框中获取记录的值和ID。。。。我在表中对每个记录使用comboBox下拉列表,所以我不能通过css ID来获取comboBox值。。。我已经成功地访问了所选记录的输入组合框,并通过对其应用背景色进行了此测试。我已经测试了.val(),它只适用于输入文本框,但不适用于剑道组合框 非常感谢 输入 jQuery函数 看一看剑道,它确实显示了你对什么感兴趣 var fabric = $("#fabric").data("kendoCom
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元素中的方法,而不是剑道控件。考虑这一点:
因此,在您的情况下,请执行以下操作:
$(this).closest('table').find("._MarkSchemeId_Input").data("kendoComboBox").text()
看一看剑道,它确实显示了你对什么感兴趣
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元素中的方法,而不是剑道控件。考虑这一点:
因此,在您的情况下,请执行以下操作:
$(this).closest('table').find("._MarkSchemeId_Input").data("kendoComboBox").text()
根据设计,ComboBox小部件将所有样式和CSS类从原始元素复制到可见输入。这是有案可查的。如果检查呈现的HTML,它将如下所示:
- 原始元素+初始化代码
我准备了一个简单的jsBin演示,演示了如何实现这一点。通过设计,ComboBox小部件将所有样式和CSS类从原始元素复制到可见输入。这是有案可查的。如果检查呈现的HTML,它将如下所示:
- 原始元素+初始化代码
我准备了一个简单的jsBin演示,演示了如何实现这一点。我已设法解决了以下问题
<td class="N_td">@Html.TextBox("Input_MarkingSchemeTitle_Element", null, new { id = @item.ElementID + "_EMST", @class = "ElementMarkingSchemeTitle k1-grid-input k-textbox_3 _MarkScheme_Input" }) </td>
//--get all the MarkScheme from database and put in drop-down
$("._MarkScheme_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()); //if it need to test selected record data...
}
});
$("#ElementTable").on("click", ".k1-grid-confirm", function () {
$(this).closest('table').find("._MarkScheme_Input").css("background", "red");
//read all the input 'comboxBox' in loop...
//var _comboBoxInput = $(this).closest('table').find("._MarkScheme_Input").filter("[data-role=combobox]");
//_comboBoxInput.each(function (idx, input) {
// alert("idx " + idx + " \n input " + input);
// var combobox = $(input).data("kendoComboBox");
// alert("ID>>> : " + combobox.value() + ", Text: >>> " + combobox.text());
//});
//-------------------------
var input = $(this).closest('table').find("._MarkScheme_Input");
var comboboxInput = input.filter("[data-role=combobox]");
var combobox = comboboxInput.data("kendoComboBox");
var selectedText = combobox.text();
var selectedValue = combobox.value();
var dataItem = combobox.dataItem();
alert("ID>>> : " + selectedValue + ", Text: >>> " + selectedText);
@Html.TextBox(“Input_-MarkingSchemeTitle_元素”,null,新建{id=@item.ElementID+“_-EMST”,@class=“ElementMarkingSchemeTitle k1网格输入k-TextBox_3_-MarkScheme_-Input”})
//--从数据库中获取所有MarkScheme并放入下拉列表
$(“.u标记方案\输入”).kendoComboBox({
最小长度:1,
筛选器:“包含”,
dataTextField:“名称”,
dataValueField:“ID”,
数据源:{
键入:“json”,
服务器筛选:false,
运输:{
阅读:“/Qualification/GetAllMarkScheme\u JSON”
},
},
更改:函数(){
//警报(“value”+this.value()+“”+this.text());//如果需要测试选定的记录数据。。。
}
});
$(“#ElementTable”)。在(“单击”,“.k1网格确认”,函数(){
$(this).closest('table').find(“.u-MarkScheme\u-Input”).css(“背景”,“红色”);
//读取循环中的所有输入“comboxBox”。。。
//var\u comboBoxInput=$(this).closest('table').find(“.\u MarkScheme\u Input”).filter(“[data role=combobox]”);
//_comboBoxInput.each(函数(idx,输入){
//警报(“idx”+idx+“\n输入”+input);
//变量组合框=$(输入).data(“kendoComboBox”);
//警报(“ID>>>:“+combobox.value()+”,文本:>>>“+combobox.Text());
//});
//-------------------------
var输入=$(this).closest('table').find('u MarkScheme_input');
var comboboxInput=input.filter(“[data role=combobox]”);
var combobox=comboboxInput.data(“kendoComboBox”);
var selectedText=combobox.text();
var selectedValue=combobox.value();
var dataItem=combobox.dataItem();
警报(“ID>>>:“+selectedValue+”,文本:>>>“+selectedText”);
我已设法解决以下问题
<td class="N_td">@Html.TextBox("Input_MarkingSchemeTitle_Element", null, new { id = @item.ElementID + "_EMST", @class = "ElementMarkingSchemeTitle k1-grid-input k-textbox_3 _MarkScheme_Input" }) </td>
//--get all the MarkScheme from database and put in drop-down
$("._MarkScheme_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()); //if it need to test selected record data...
}
});
$("#ElementTable").on("click", ".k1-grid-confirm", function () {
$(this).closest('table').find("._MarkScheme_Input").css("background", "red");
//read all the input 'comboxBox' in loop...
//var _comboBoxInput = $(this).closest('table').find("._MarkScheme_Input").filter("[data-role=combobox]");
//_comboBoxInput.each(function (idx, input) {
// alert("idx " + idx + " \n input " + input);
// var combobox = $(input).data("kendoComboBox");
// alert("ID>>> : " + combobox.value() + ", Text: >>> " + combobox.text());
//});
//-------------------------
var input = $(this).closest('table').find("._MarkScheme_Input");
var comboboxInput = input.filter("[data-role=combobox]");
var combobox = comboboxInput.data("kendoComboBox");
var selectedText = combobox.text();
var selectedValue = combobox.value();
var dataItem = combobox.dataItem();
alert("ID>>> : " + selectedValue + ", Text: >>> " + selectedText);
@Html.TextBox(“Input_-MarkingSchemeTitle_元素”,null,新建{id=@item.ElementID+“_-EMST”,@class=“ElementMarkingSchemeTitle k1网格输入k-TextBox_3_-MarkScheme_-Input”})
//--从数据库中获取所有MarkScheme并放入下拉列表
$(“.u标记方案\输入”).kendoComboBox({
最小长度:1,
筛选器:“包含”,
dataTextField:“名称”,
dataValueField:“ID”,
数据源:{
键入:“json”,
服务器筛选:false,
运输:{
阅读:“/Qualification/GetAllMarkScheme\u JSON”
},
},
更改:函数(){
//警报(“value”+this.value()+“”+this.text());//如果需要测试选定的记录数据。。。
}
});
$(“#ElementTable”)。在(“单击”,“.k1网格确认”,函数(){
$(this).closest('table').find(“.u-MarkScheme\u-Input”).css(“背景”,“红色”);
//读取循环中的所有输入“comboxBox”。。。
//var\u comboBoxInput=$(this).closest('table').find(“.\u MarkScheme\u Input”).filter(“[data role=combobox]”);
//_comboBoxInput.each(函数(idx,输入){
//警报(“idx”+idx+“\n输入”+input);
//变量组合框=$(输入).data(“kendoComboBox”);
//警报(“ID>>>:“+combobox.value()+”,文本:>>>“+combobox.Text());
//});
//-------------------------
var输入=$(this).closest('table').find('u MarkScheme_input');
var comboboxInput=input.filter(“[data role=combobox]”);
var combobox=comboboxInput.data(“kendoComboBox”);
var selectedText=combobox.text();
var selectedValue=combobox.value();
var dataItem=combobox.dataItem();
警报(“ID>>>:“+selectedValue+”,文本:>>>“+selectedText”);
我已将use data.kendo和use value()与之一起用于ge
<input class="custom-class" />
<script>
$(function() {
$(".custom-class").kendoComboBox();
});
</script>
<span class="k-widget k-combobox k-header custom-class">
<span tabindex="-1" unselectable="on" class="k-dropdown-wrap k-state-default">
<input class="k-input custom-class" type="text" autocomplete="off" style="width: 100%;">
<span tabindex="-1" unselectable="on" class="k-select">
<span unselectable="on" class="k-icon k-i-arrow-s" role="button" tabindex="-1">
select
</span>
</span>
</span>
<input class="custom-class" data-role="combobox" style="display: none;">
</span>
$(".custom-class[data-role=combobox]");
<td class="N_td">@Html.TextBox("Input_MarkingSchemeTitle_Element", null, new { id = @item.ElementID + "_EMST", @class = "ElementMarkingSchemeTitle k1-grid-input k-textbox_3 _MarkScheme_Input" }) </td>
//--get all the MarkScheme from database and put in drop-down
$("._MarkScheme_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()); //if it need to test selected record data...
}
});
$("#ElementTable").on("click", ".k1-grid-confirm", function () {
$(this).closest('table').find("._MarkScheme_Input").css("background", "red");
//read all the input 'comboxBox' in loop...
//var _comboBoxInput = $(this).closest('table').find("._MarkScheme_Input").filter("[data-role=combobox]");
//_comboBoxInput.each(function (idx, input) {
// alert("idx " + idx + " \n input " + input);
// var combobox = $(input).data("kendoComboBox");
// alert("ID>>> : " + combobox.value() + ", Text: >>> " + combobox.text());
//});
//-------------------------
var input = $(this).closest('table').find("._MarkScheme_Input");
var comboboxInput = input.filter("[data-role=combobox]");
var combobox = comboboxInput.data("kendoComboBox");
var selectedText = combobox.text();
var selectedValue = combobox.value();
var dataItem = combobox.dataItem();
alert("ID>>> : " + selectedValue + ", Text: >>> " + selectedText);