0
有沒有辦法將信息添加到asp:TreeView中,方法是通過JavaScript/Jquery訪問它?我的問題:我必須通過JQuery/Javascript(在客戶端)阻止asp:TreeView中的複選框可以在不同的子類別(或通過構造型前綴分組的父類節點)中選擇。當我向$(this).next()。text()請求TreeNode-Text時,它已經工作了,因爲它們在類別中有一個前綴(原型),但現在我必須隱藏該信息並且不能使用它去檢查。<asp:TreeView>通過JavaScript/JQuery向treenode添加更多信息?
$("[id*=TreeView1] input[type=checkbox]").bind("click", function() {
var isChecked = $(this).is(":checked");
if (isChecked) {
zuletztSelektiert = zuletztSelektiert + $(this).next().text();
}
else {
zuletztSelektiert = zuletztSelektiert.replace($(this).next().text(), '');
}
if (zuletztSelektiert != '') {
// Welcher Stereotyp ist selektiert?
var stereotype = zuletztSelektiert.substring(zuletztSelektiert.indexOf('«') + 1, zuletztSelektiert.indexOf('»'));
$("[id*=TreeView1] input[type=checkbox]").each(function() {
var currentStereotype = $(this).next().text().substring($(this).next().text().indexOf('«') + 1, $(this).next().text().indexOf('»'));
if (currentStereotype != stereotype) {
var isChecked2 = $(this).is(":checked");
if (isChecked2) {
$(this).removeAttr("checked");
zuletztSelektiert = zuletztSelektiert.replace($(this).next().text(), '');
alert('It is not possible to select elements of different stereotypes. \n\n Selected Items:\n' + zuletztSelektiert);
}
}
});
}
});
嗨!通過向目標URL添加原型來解決它,因爲我沒有找到方法。 –