DDR爱好者之家 Design By 杰米
下载地址:jQuery EasyUI API 中文帮助文档
1.validatebox验证和提示框扩展:
//弹框 $.extend({ show_alert: function (strTitle, strMsg) { $.messager.alert(strTitle, strMsg); } }); //扩展validatebox,添加验证 $.extend($.fn.validatebox.defaults.rules, { eqPwd: { validator: function (value, param) { return value == $(param[0]).val(); }, message: '密码不一致!' }, idcard: {// 验证身份证 validator: function (value) { return /^\d{15}(\d{2}[A-Za-z0-9])"必须介于{0}和{1}之间." }, phone: {// 验证电话号码 validator: function (value) { return /^((\d2,3)|(\d{3}\-))"#" + param[0]).val() != "" && value != "") { return $("#" + param[0]).val() == value; } else { return true; } }, message: '两次输入的密码不一致!' } });
使用方法:(红色标记)
<input type="text" name="txtUserNameEdit" id="txtUserNameEdit" class="easyui-validatebox textbox" data-options="required:true,validType:'length[2,20]'" style="width:170px;height:22px;" /> <input type="text" name="txtMobilePhone" id="txtMobilePhone" class="easyui-validatebox textbox" data-options="required:false,validType:'mobile'" style="width:170px;height:22px;" />
2.datagrid动态输出列:
前端JS输出:
//动态构造列表 var option = {}; $.ajax({ url: "/Table/GetTabColsJsonStr", type: "post", data: {}, dataType: "json", success: function (data) { option.columns = data.columns; $("#ui_TabData_dg").datagrid({ url: "/Table/GetTabDataInfoByTabId", striped: true, rownumbers: true, pagination: true, pageSize: 20, singleSelect: true, multiSort: true, idField: 'Id', sortName: 'UpdateTime', sortOrder: 'desc', pageList: [20, 40, 60, 80, 100] }); $('#ui_TabData_dg').datagrid(option); } })
后端:
/// <summary> /// 获取列Json /// </summary> /// <param name="TabId"></param> /// <returns></returns> public string GetColumnsJsonStr() { string fieldJson = "{\"columns\":[[{\"field\":\"Id\",\"title\":\"主键\",\"width\":\"40\"},"; //此处获取输出表的列... DataTable dtFields = new DataTable(); //SqlHelper.GetDataTable.... if (dtFields.Rows.Count > 0) { foreach (DataRow dr in dtFields.Rows) { fieldJson += "{\"field\":\"" + dr["FieldName"].ToString() + "\",\"title\":\"" + dr["FieldViewName"].ToString() + "\",\"width\":\"100\"},"; } } fieldJson += "{\"field\":\"CreateBy\",\"title\":\"创建人\",\"width\":\"80\"},"; fieldJson += "{\"field\":\"CreateTime\",\"title\":\"创建时间\",\"width\":\"130\"},"; fieldJson += "]]}"; return fieldJson; }
3.easyui-accordion和easyui-tree构造多层级目录一级选项卡菜单框架
如下图:
菜单树HTML:
<div data-options="region:'west',split:true,title:'功能导航'" style="width: 180px; background-color: white;"> <div id="RightAccordion" class="easyui-accordion"> </div> </div> <div data-options="region:'center'"> <div id="tabs" class="easyui-tabs" fit="true" border="false" data-options=" tools:[ {iconCls : 'icon-arrow_refresh',text:'刷新',handler:refreshTab}, {iconCls : 'icon-delete3',text:'关闭全部',handler:closeTab} ]"> <div id="home" title="我的主页" data-options="iconCls:'icon-house',closable:false" style="padding:10px"> This is the Home content. </div> </div> </div>
JS:
function BindRightAccordion() { $("#RightAccordion").accordion({ //初始化accordion fillSpace: true, fit: true, border: false, animate: false }); //获取第一层初始目录 $.post("/Home/GetTreeByEasyui", { "id": "0" }, function (data) { if (data == "0") { window.location.href = '/Login/Index'; } $.each(data, function (i, e) { var id = e.id; $('#RightAccordion').accordion('add', { title: e.text, content: "<ul id='tree" + id + "' ></ul>", selected: true, iconCls: e.iconCls }); $.parser.parse(); //获取二级以下目录 含2级 $.post("/Home/GetTreeByEasyui" + id, function (data) { $("#tree" + id).tree({ data: data, onBeforeExpand: function (node, param) { $("#tree" + id).tree('options').url = "/Home/GetTreeByEasyui" + node.id; }, onClick: function (node) { if (node.state == 'closed') { $(this).tree('expand', node.target); } else if (node.state == 'open') { $(this).tree('collapse', node.target); var tabTitle = node.text; var url = node.attributes; var icon = node.iconCls; addTab(tabTitle, url, icon); } } }); }, 'json'); }); }, "json"); } //选项卡 function addTab(subtitle, url, icon) { var strHtml = '<iframe id="frmWorkArea" width="99.5%" height="99%" style="padding:1px;" frameborder="0" scrolling="yes" src="/UploadFiles/2021-04-02/' + url + '">后端输出Json代码:
/// <summary> /// 获取导航菜单 /// </summary> /// <param name="id">所属</param> /// <returns>树</returns> public JsonResult GetTreeByEasyui(string id) { try { if (uInfo != null) { DataTable dt = new MenuBLL().GetUserMenuData( int.Parse(id)); List<SysModuleNavModel> list = new List<SysModuleNavModel>(); for (int i = 0; i < dt.Rows.Count; i++) { SysModuleNavModel model = new SysModuleNavModel(); model.id = dt.Rows[i]["menuid"].ToString(); model.text = dt.Rows[i]["menuname"].ToString(); model.attributes = dt.Rows[i]["linkaddress"].ToString(); model.iconCls = dt.Rows[i]["icon"].ToString(); if (new MenuBLL().GetMenuList(" AND ParentId= " + model.id).Rows.Count > 0) { model.state = "closed"; } else { model.state = "open"; } list.Add(model); } return Json(list); } else { return Json("0", JsonRequestBehavior.AllowGet); } } catch (Exception ex) { return Json("0", JsonRequestBehavior.AllowGet); } } public class SysModuleNavModel { public string id { get; set; } public string text { get; set; } public string iconCls { get; set; } public string attributes { get; set; } public string state { get; set; } public List<SysModuleNavModel> children { get; set; } }3.dialog弹出窗口:
(1)内容页为iframe:
//采用iframe框架 function ShowNews() { var content = '<iframe src="/UploadFiles/2021-04-02/ShowNews">(2)内容页为div:
//div function ShowNews() { $("<div/>").dialog({ id: "ui_news_dialog", title: "公告", href: "/News/ShowNews", height: 600, width: 800, modal: true, buttons: [{ id: "ui_AddNews_btn",//按钮ID text: '添 加', handler: function () { //这里写form表单提交事件 $("#NewsForm").form("submit", { url: "/News/AddNews", onSubmit: function (param) { param.ID = ""; param.Name = ""; if ($(this).form('validate')) { return true; } else { return false; } }, success: function (data) { var dataJson = eval('(' + data + ')'); if (dataJson.success) { //销毁dialog对象 $("#ui_news_dialog").dialog('destroy'); $.show_alert("提示", dataJson.msg); } else { $.show_alert("提示", dataJson.msg); } } }); } }, { text: '取 消', handler: function () { $("#ui_news_dialog").dialog('destroy'); } }], onLoad: function () { //加载处理事件,例如: $("#txtName").focus(); }, onClose: function () { $("#ui_news_dialog").dialog('destroy'); } }); }以上所述是小编给大家介绍的jQuery EasyUI API 中文帮助文档和扩展实例,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米
暂无评论...
更新日志
2024年11月29日
2024年11月29日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]