在 jqxListBox({}) 中将 ID 和值添加到 CheckBox
ADD ID and Value to CheckBox in jqxListBox({})
我需要为列表框中的复选框添加 ID
<input type=”checkbox” name=”vehicle” id = 1>Code</br>
<input type=”checkbox” name=”vehicle” id = 2>Select
一旦我 select CheckBox 并且我需要获取 CheckBox Id 并且我还可以勾选基于 ID 的 CheckBox 怎么办????
但这里不能添加那个
var source = [
"Affogato",
"Caffé Latte"];
// Create a jqxListBox
$(“#jqxListBox”).jqxListBox({
source: source,
theme: ‘energyblue’,
width: ’200px’,
height: ’250px’,
checkboxes:true
});
您可以使用 checkChange
事件,在您的情况下,源应该有两个值(1 - displayMember,2 - valueMember):
var source = [{
vehicle: "Affogato",
id: 122
}, {
vehicle: "Americano",
id: 156
}, {
vehicle: "Bicerin",
id: 1023
}, {
vehicle: "Breve",
id: 4567
}];
$("#jqxListBox").jqxListBox({
source: source,
displayMember: "vehicle",
valueMember: "id",
checkboxes: true
});
$("#jqxListBox").on('checkChange', function (event) {
var args = event.args;
// get new check state.
var checked = args.checked;
// get the item and it's label and value fields.
var item = args.item;
var itemLabel = item.label;
var itemValue = item.value;
});
我需要为列表框中的复选框添加 ID
<input type=”checkbox” name=”vehicle” id = 1>Code</br>
<input type=”checkbox” name=”vehicle” id = 2>Select
一旦我 select CheckBox 并且我需要获取 CheckBox Id 并且我还可以勾选基于 ID 的 CheckBox 怎么办????
但这里不能添加那个
var source = [
"Affogato",
"Caffé Latte"];
// Create a jqxListBox
$(“#jqxListBox”).jqxListBox({
source: source,
theme: ‘energyblue’,
width: ’200px’,
height: ’250px’,
checkboxes:true
});
您可以使用 checkChange
事件,在您的情况下,源应该有两个值(1 - displayMember,2 - valueMember):
var source = [{
vehicle: "Affogato",
id: 122
}, {
vehicle: "Americano",
id: 156
}, {
vehicle: "Bicerin",
id: 1023
}, {
vehicle: "Breve",
id: 4567
}];
$("#jqxListBox").jqxListBox({
source: source,
displayMember: "vehicle",
valueMember: "id",
checkboxes: true
});
$("#jqxListBox").on('checkChange', function (event) {
var args = event.args;
// get new check state.
var checked = args.checked;
// get the item and it's label and value fields.
var item = args.item;
var itemLabel = item.label;
var itemValue = item.value;
});