DevExtreme dxList 在鼠标悬停时更改 itemTemplate
DevExtreme dxList change itemTemplate on mouse over
我有 DevExtreme dxList:
<div data-bind="dxList: { dataSource: ds, itemTemplate: tpl }">
</div>
var vm = {
ds: [{
"key": "group1",
"items": [{ name: "item1" }, { name: "item2" }]
}],
tpl: function() {
var r = '<div data-options="dxTemplate:{ name:\'tpl\' }">';
r += '<div data-bind="dxCheckBox: { text: name }"></div>';
r += '</div>';
return r;
}
};
};
ko.applyBindings(vm);
如何仅针对特定项目更改 itemTemplate 运行-time? (例如鼠标悬停)
要更改列表项模板,您可以使用以下示例 http://jsfiddle.net/oakvprw9/8/
这是示例项目模板:
<div data-bind="dxList: { dataSource: dataSource, onItemClick: onItemClick }">
<div data-options="dxTemplate: { name: 'item' }">
<div>
<span data-bind="text: text, visible: !editEnabled()"></span>
<div data-bind="visible: editEnabled">
<div data-bind="dxTextBox: { value: text }"></div>
<div data-bind="dxButton: { text: 'Save', onClick: $root.saveChanges }"></div>
<div data-bind="dxButton: { text: 'Cancel', onClick: $root.cancelChanges }"></div>
</div>
</div>
</div>
我有 DevExtreme dxList:
<div data-bind="dxList: { dataSource: ds, itemTemplate: tpl }">
</div>
var vm = {
ds: [{
"key": "group1",
"items": [{ name: "item1" }, { name: "item2" }]
}],
tpl: function() {
var r = '<div data-options="dxTemplate:{ name:\'tpl\' }">';
r += '<div data-bind="dxCheckBox: { text: name }"></div>';
r += '</div>';
return r;
}
};
};
ko.applyBindings(vm);
如何仅针对特定项目更改 itemTemplate 运行-time? (例如鼠标悬停)
要更改列表项模板,您可以使用以下示例 http://jsfiddle.net/oakvprw9/8/
这是示例项目模板:
<div data-bind="dxList: { dataSource: dataSource, onItemClick: onItemClick }">
<div data-options="dxTemplate: { name: 'item' }">
<div>
<span data-bind="text: text, visible: !editEnabled()"></span>
<div data-bind="visible: editEnabled">
<div data-bind="dxTextBox: { value: text }"></div>
<div data-bind="dxButton: { text: 'Save', onClick: $root.saveChanges }"></div>
<div data-bind="dxButton: { text: 'Cancel', onClick: $root.cancelChanges }"></div>
</div>
</div>
</div>