Devexpress MVC DropDownList (持续更新))
@Html.DevExpress().DropDownEdit(settings =>
{
settings.Name = "psBankCharge";
settings.ControlStyle.Border.BorderColor = System.Drawing.Color.LightGray;
settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
settings.Height = System.Web.UI.WebControls.Unit.Pixel(34);
settings.ControlStyle.CssClass = "form-control dx-dropdown";
settings.Properties.NullText = @Utils.GetTranslation("Select") + " " + @Utils.GetTranslation("Bank Charge");
settings.Properties.NullTextStyle.CssClass = ":-moz-placeholder";
settings.Properties.DropDownWindowStyle.BackColor = System.Drawing.Color.FromArgb(0xEDEDED); settings.SetDropDownWindowTemplateContent(c =>
{
@Html.DevExpress().ListBox(
listBoxSettings =>
{
listBoxSettings.Name = "lbBankCharge";
listBoxSettings.ControlStyle.Border.BorderWidth = 0;
listBoxSettings.ControlStyle.BorderBottom.BorderWidth = 1;
listBoxSettings.ControlStyle.Border.BorderColor = System.Drawing.Color.LightGray;
listBoxSettings.ControlStyle.BorderBottom.BorderColor = System.Drawing.Color.FromArgb(0xDCDCDC);
listBoxSettings.Height = System.Web.UI.WebControls.Unit.Pixel(200);
listBoxSettings.Width = System.Web.UI.WebControls.Unit.Percentage(99.99);
listBoxSettings.Properties.SelectionMode = ListEditSelectionMode.CheckColumn;
listBoxSettings.Properties.ClientSideEvents.SelectedIndexChanged = "function(s, e){ ListBoxMultipleSelectionChanged(psBankCharge, s, e);}";
listBoxSettings.Properties.ValueType = typeof(string);
listBoxSettings.Properties.Items.Add("(Select all)");
foreach (ListEditItem item in (System.Collections.IEnumerable)ViewData["BankCharge"])
{
listBoxSettings.Properties.Items.Add(item.Text, item.Value);
}
}
).Render();
ViewContext.Writer.Write("<div style=\"margin: 6px; overflow hidden;\">");
@Html.DevExpress().Button(
buttonSettings =>
{
buttonSettings.Name = "btnCloseBankCharge";
buttonSettings.Text = "Close";
buttonSettings.ControlStyle.CssClass = "btn btn-default";
buttonSettings.ClientSideEvents.Click = "function(s, e){ psBankCharge.HideDropDown(); }";
}
).Render();
ViewContext.Writer.Write("</div>");
}); settings.DisabledStyle.BackColor = System.Drawing.Color.FromArgb(0xEEEEEE);
settings.Properties.AnimationType = DevExpress.Web.AnimationType.None;
settings.Properties.ClientSideEvents.TextChanged = "function(s, e){ SynchronizeListBoxMultipleValues(s, lbBankCharge); }";
settings.Properties.ClientSideEvents.DropDown = "function(s, e){ SynchronizeListBoxMultipleValues(s, lbBankCharge); }";
}).GetHtml()
//选中指定的Item,
SelectItemByValue(cboModalDepCode,lboModalDepCode,Value);
全部取消选中(多选)
ResetListBox(cboSearchDepCode, lboSearchDepCode);
全部取消选中(单选)
ResetSingleListBox(cboSearchDateOption,lboSearchDateOption);
获取选中的值(单选)
GetValuesByTexts(GetSelectedItemsText_Single(lboModalPackType.GetSelectedItems()), lboModalPackType);
获取选中的值(多选)
GetValuesByTexts(GetSelectedItemsText(lbBraCode.GetSelectedItems()).split(gs_TextSeparator),lbBraCode)
var gs_TextSeparator = ",";
function UpdateSelectAllItemState(ao_lbListBox) {
IsAllSelected(ao_lbListBox) ? ao_lbListBox.SelectIndices([0]) : ao_lbListBox.UnselectIndices([0]);
}
function IsAllSelected(ao_lbListBox) {
for (var i = 1; i < ao_lbListBox.GetItemCount() ; i++)
if (!ao_lbListBox.GetItem(i).selected)
return false;
return true;
}
function UpdateText(ao_lbListBox, ao_ddlDropDown, ab_IsSingle) {
if (ab_IsSingle)
ao_ddlDropDown.SetText(GetSelectedItemsText_Single(ao_lbListBox.GetSelectedItems()));
else
ao_ddlDropDown.SetText(GetSelectedItemsText(ao_lbListBox.GetSelectedItems()));
}
function GetSelectedItemsText(aa_Items) {
var la_Texts = [];
for (var i = 0; i < aa_Items.length; i++)
if (aa_Items[i].index != 0)
la_Texts.push(aa_Items[i].text);
return la_Texts.join(gs_TextSeparator);
}
function GetSelectedItemsText_Single(aa_Items) {
var la_Texts = [];
for (var i = 0; i < aa_Items.length; i++)
la_Texts.push(aa_Items[i].text);
return la_Texts;
}
function GetValuesByTexts(aa_Text, ao_lbListBox) {
var la_ActualTexts = [];
var ls_Item;
for (var i = 0; i < aa_Text.length; i++) {
ls_Item = ao_lbListBox.FindItemByText(aa_Text[i]);
if (ls_Item != null) {
la_ActualTexts.push( ls_Item.value );
} else {
la_ActualTexts.push("");
}
}
return la_ActualTexts;
}
function GetQuotesValuesByTexts(aa_Text, ao_lbListBox,as_Quotes) {
var la_ActualTexts = [];
var ls_Item;
for (var i = 0; i < aa_Text.length; i++) {
ls_Item = ao_lbListBox.FindItemByText(aa_Text[i]);
if (ls_Item != null) {
la_ActualTexts.push(as_Quotes + ls_Item.value + as_Quotes);
} else {
la_ActualTexts.push("");
}
}
return la_ActualTexts;
}
function GetTextsByValues(aa_Value, ao_lbListBox) {
var la_ActualTexts = [];
var ls_Item;
for (var i = 0; i < aa_Value.length; i++) {
ls_Item = ao_lbListBox.FindItemByValue(aa_Value[i]);
if (ls_Item !== null)
la_ActualTexts.push(ls_Item.text);
}
return la_ActualTexts;
}
function SelectItemByValue(ao_ddlDropDown, ao_lbListBox, as_Value) {
for (var i = 0; i < ao_lbListBox.GetItemCount() ; i++) {
if (ao_lbListBox.GetItem(i).value == as_Value) {
ao_lbListBox.SetSelectedIndex(i);
break;
}
}
UpdateText(ao_lbListBox, ao_ddlDropDown, true);
}
function SetSelectItemByText(ao_ddlDropDown, ao_lbListBox, as_Text) {
for (var i = 0; i < ao_lbListBox.GetItemCount() ; i++) {
if (ao_lbListBox.GetItem(i).text == as_Text) {
ao_lbListBox.SetSelectedIndex(i);
break;
}
}
UpdateText(ao_lbListBox, ao_ddlDropDown, true);
}
function SynchronizeListBoxValues(ao_ddlDropDown, ao_lbListBox) {
var la_Texts = ao_ddlDropDown.GetText().split(gs_TextSeparator);
var la_Values = GetValuesByTexts(la_Texts, ao_lbListBox);
ao_lbListBox.SelectValues(la_Values);
UpdateText(ao_lbListBox, ao_ddlDropDown, true);
}
function ListBoxSelectionChanged(ao_ddlDropDown, ao_lbListBox) {
UpdateText(ao_lbListBox, ao_ddlDropDown, true);
ao_ddlDropDown.HideDropDown();
}
function InitDropDown(ao_ddlDropDown, ao_lbListBox) {
ao_lbListBox.SetSelectedIndex(0);
UpdateText(ao_lbListBox, ao_ddlDropDown, true);
}
function ListBoxMultipleSelectionChanged(ao_ddlDropDown, ao_lbListBox, ao_lbListBoxEvent) {
if (ao_lbListBoxEvent.index === 0)
ao_lbListBoxEvent.isSelected ? ao_lbListBox.SelectAll() : ao_lbListBox.UnselectAll();
UpdateSelectAllItemState(ao_lbListBox);
UpdateText(ao_lbListBox, ao_ddlDropDown, false);
}
function SynchronizeListBoxMultipleValues(ao_ddlDropDown, ao_lbListBox) {
ao_lbListBox.UnselectAll();
var la_Texts = ao_ddlDropDown.GetText().split(gs_TextSeparator);
var la_Values = GetValuesByTexts(la_Texts, ao_lbListBox);
ao_lbListBox.SelectValues(la_Values);
UpdateSelectAllItemState(ao_lbListBox);
UpdateText(ao_lbListBox, ao_ddlDropDown, false);
}
function ResetListBox(ao_ddlDropDown, ao_lbListBox) {
ao_lbListBox.UnselectAll();
ao_ddlDropDown.SetText(null);
}
function ResetSingleListBox(ao_ddlDropDown, ao_lbListBox) {
ao_lbListBox.SetSelectedIndex(0);
UpdateText(ao_lbListBox, ao_ddlDropDown, true);
}
Devexpress MVC DropDownList (持续更新))的更多相关文章
- MVC设计模式(持续更新中)
MVC设计模式--->英文全称为: model(模型) View (视图) Controller(控制) MVC是一种设计思想.这种思想强调实现模型(Model).视图(View)和控制 ...
- 蒋金楠How ASP.NET MVC Works?[持续更新中…]
一.ASP.NET + MVC IIS与ASP.NET管道 MVC.MVP以及Model2[上篇] MVC.MVP以及Model2[下篇] ASP.NET MVC是如何运行的[1]: 建立在“伪”M ...
- ASP.NET MVC 5 系列 学习笔记 目录 (持续更新...)
前言: 记得当初培训的时候,学习的还是ASP.NET,现在回想一下,图片水印.统计人数.过滤器....HttpHandler是多么的经典! 不过后来接触到了MVC,便立马爱上了它.Model-View ...
- 关于ASP.NET MVC开发设计中出现的问题与解决方案汇总 【持续更新】
最近一直用ASP.NET MVC 4.0 +LINQ TO SQL来开发设计公司内部多个业务系统网站,在这其中发现了一些问题,也花了不少时间来查找相关资料或请教高人,最终都还算解决了,现在我将这些问题 ...
- ASP.NET MVC深入浅出系列(持续更新) ORM系列之Entity FrameWork详解(持续更新) 第十六节:语法总结(3)(C#6.0和C#7.0新语法) 第三节:深度剖析各类数据结构(Array、List、Queue、Stack)及线程安全问题和yeild关键字 各种通讯连接方式 设计模式篇 第十二节: 总结Quartz.Net几种部署模式(IIS、Exe、服务部署【借
ASP.NET MVC深入浅出系列(持续更新) 一. ASP.NET体系 从事.Net开发以来,最先接触的Web开发框架是Asp.Net WebForm,该框架高度封装,为了隐藏Http的无状态模 ...
- ( 译、持续更新 ) JavaScript 上分小技巧(一)
感谢好友破狼提供的这篇好文章,也感谢写这些知识点的作者们和将他们整理到一起的作者.这是github上的一篇文章,在这里本兽也就只做翻译,由于本兽英语水平和编程能力都不咋地,如有不好的地方也请多理解体谅 ...
- [渣译文] 使用 MVC 5 的 EF6 Code First 入门 系列:为ASP.NET MVC应用程序更新相关数据
这是微软官方教程Getting Started with Entity Framework 6 Code First using MVC 5 系列的翻译,这里是第八篇:为ASP.NET MVC应用程序 ...
- ASP.NET MVC应用程序更新相关数据
为ASP.NET MVC应用程序更新相关数据 这是微软官方教程Getting Started with Entity Framework 6 Code First using MVC 5 系列的翻译, ...
- 【 js 基础 】【 源码学习 】源码设计 (持续更新)
学习源码,除了学习对一些方法的更加聪明的代码实现,同时也要学习源码的设计,把握整体的架构.(推荐对源码有一定熟悉了之后,再看这篇文章) 目录结构:第一部分:zepto 设计分析第二部分:undersc ...
随机推荐
- 简述在Js或Vue中监听页面的刷新、关闭操作
1.背景 大家是否经常遇到在关闭网页的时候,会看到一个确定是否离开当前页面的提示框?想一些在线测试系统.信息录入系统等就经常会有这一些提示,避免用户有意或者无意中关掉了页面,导致数据丢失.而最近在做项 ...
- Elasticsearch-集群增加节点
ES-在集群中加入节点 查看分片信息 FengZhendeMacBook-Pro:nacos FengZhen$ curl 'localhost:9200/_cat/shards?v' index s ...
- PostgreSQL INSERT ON CONFLICT不存在则插入,存在则更新
近期有一个需求,向一张数据库表插入数据,如果是新数据则执行插入动作,如果插入的字段和已有字段重复,则更新该行对应的部分字段 1. 创建测试表 create table meta_data ( id s ...
- idea运行时 Process finished with exit code -1073741819 (0xC0000005)
问题描述: idea中启动项目报 Process finished with exit code -1073741819 (0xC0000005) ,如图所示: 问题解决: ...
- eclipse 逆向生成hbm配置文件及pojo
1.eclipse配置hibernate环境 由于在公司中不能在线安装jboss Tools,只能简单介绍手动安装 在jboss官网下载对应自己eclipse的压缩包. 在eclipse 中选择Hel ...
- Linux 中将用户添加到指定组
添加组 usermod -a -G root dev 修改组 usermod -g root dec 删除组 gpasswd -d dev root gpasswd -a dev root //将用户 ...
- 文件的三种打开方式及with管理文件上下文
文件的三种打开方式及with管理文件上下文 一.文件的三种打开方式 1.1 只读 f = open(r'D:\pycharm\yjy\上海python学习\456.txt','r',encoding= ...
- KNN-机器学习算法
''' Created on Sep 16, 2010 kNN: k Nearest Neighbors Input: inX: vector to compare to existing datas ...
- WebApi 生成帮助文档及顺便创建简单的测试工具
http://www.2cto.com/kf/201607/522971.html ==========最终的效果图========== ==========下面开始干活========== 一.创建 ...
- Linux操作系统笔记
#include <stdio.h> #include <stdlib.h> #include <unistd.h> //linux下面的头文件 #include ...