如何使用context menu移动TreeList节点?
作者: 来源: 浏览:Loading...次 发布时间:今天 (07:27) 评论:0条
如果TreeList层级比较多,通过滚动一个control/page去找到目标节点,非常方便。
下面分享一下实现这个功能的源代码。
平台产品:DevExpress ASP.NET MVC
子控件:MVC TreeList
$(function () {
// Cache for dialogs
var dialogs = {};
var getValidationSummaryErrors = function ($form) {
// We verify if we created it beforehand
var errorSummary = $form.find('.validation-summary-errors, .validation-summary-valid');
if (!errorSummary.length) {
errorSummary = $('<div class="validation-summary-errors"><span>Please correct the errors and try again.</span><ul></ul></div>')
.prependTo($form);
}
return errorSummary;
};
var displayErrors = function (form, errors) {
var errorSummary = getValidationSummaryErrors(form)
.removeClass('validation-summary-valid')
.addClass('validation-summary-errors');
var items = $.map(errors, function (error) {
return '<li>' + error + '</li>';
}).join('');
var ul = errorSummary
.find('ul')
.empty()
.append(items);
};
var resetForm = function ($form) {
// We reset the form so we make sure unobtrusive errors get cleared out.
$form[0].reset();
getValidationSummaryErrors($form)
.removeClass('validation-summary-errors')
.addClass('validation-summary-valid')
};
var formSubmitHandler = function (e) {
var $form = $(this);
// We check if jQuery.validator exists on the form
if (!$form.valid || $form.valid()) {
$.post($form.attr('action'), $form.serializeArray())
.done(function (json) {
json = json || {};
// In case of success, we redirect to the provided URL or the same page.
if (json.success) {
location = json.redirect || location.href;
} else if (json.errors) {
displayErrors($form, json.errors);
}
})
.error(function () {
displayErrors($form, ['An unknown error happened.']);
});
}
// Prevent the normal behavior since we opened the dialog
e.preventDefault();
};
var loadAndShowDialog = function (id, link, url) {
var separator = url.indexOf('?') >= 0 ? '&' : '?';
// Save an empty jQuery in our cache for now.
dialogs[id] = $();
// Load the dialog with the content=1 QueryString in order to get a PartialView
$.get(url + separator + 'content=1')
.done(function (content) {
dialogs[id] = $('<div class="modal-popup">' + content + '</div>')
.hide() // Hide the dialog for now so we prevent flicker
.appendTo(document.body)
.filter('div') // Filter for the div tag only, script tags could surface
.dialog({ // Create the jQuery UI dialog
title: link.data('dialog-title'),
modal: true,
resizable: true,
draggable: true,
width: link.data('dialog-width') || 600,
beforeClose: function () { resetForm($(this).find('form')); }
})
.find('form') // Attach logic on forms
.submit(formSubmitHandler)
.end();
});
};
// List of link ids to have an ajax dialog
var links = ['#loginLink', '#registerLink'];
$.each(links, function (i, id) {
$(id).click(function (e) {
var link = $(this),
url = link.attr('href');
if (!dialogs[id]) {
loadAndShowDialog(id, link, url);
} else {
dialogs[id].dialog('open');
}
// Prevent the normal behavior since we use a dialog
e.preventDefault();
});
});
});
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [http://www.devexpresscn.com/]
本文地址:http://www.devexpresscn.com/Resources/FAQ-535.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [http://www.devexpresscn.com/]
本文地址:http://www.devexpresscn.com/Resources/FAQ-535.html
关键字: DevExpress
评论列表
暂无评论
请谈谈你的看法 请使用IE或者Firefox浏览器,暂不支持Chrome!

慧都控件网为DevExpress界面控件的中国地区唯一正式授权经销商,正版控件销售公司,授权代理商,经销商及合作伙伴。
电话:400-700-1020
023-66090381
邮箱:sales@evget.com
相关资源
- CodeRush使用教程四:CodeRush键盘映射窗口
- CodeRush使用教程五:拼写检查
- CodeRush使用教程六:DXCore可视化工具栏
- CodeRush使用教程七:高级筛选选项(快速导航)
- CodeRush使用教程八:书签(Bookmarks)
- CodeRush使用教程九:Click Identifier
- CodeRush使用教程十:快速文件导航
- CodeRush使用教程十一:标签
- CodeRush使用教程十二:快捷菜单
- CodeRush使用教程十三:显示颜色
- CodeRush使用教程十四:Target Picker
- CodeRush使用教程十五:代码修复提示
- CodeRush使用教程十六:解码器
- 如何设置Devexpress新增节点后被选中
- 禁用ASPxTreeList复选框选项
- 如何自定义TreeList单元格的工具条
- 如何在XtraTreelist的每个单元格中添加下拉列表
- XtraTreeList如何绑定父子节点




