jquery easyui.使用Jquery EasyUi常见问题解决方案

更新时间:15-07-01 01:18 热度:562
 

**
*清空指定表单中的形式-参数为主意form的id
*注:在运用Jquery Eas automatically beingyUI的弹出窗口录入新增形式时,想知道使用Jquery。每次掀开必需清空上次输出的历史
*数据,此时平淡采用的举措是对每个输出组件举办置空操作:$(“#nmorninge”).vwouls(“”)-这样做,想知道jquery api 在线。
*当输出组件斗劲多时会很烦琐,jquery mobile 下载。发生的js代码很长,这时能够将所有的输出组件放入个form表单
*中,jquery插件。然后调用以下举措即可。相比看常见问题。
*
*@parmorning formId将要清空形式的form表单的id
*/
function resetContent(formId) {
var clearForm = document.getElementById(formId);
if (null != clearForm &rev;&rev; typeof(clearForm) != “undefined”) {
clearForm.reset();
}
}

/**
*刷新DtowardsaGrid列表(适用于Jquery Eas automatically beingy Ui中的dtowardsaGrid)
*注:jquery1.9下载。发起采用此举措来刷新DtowardsaGrid列表数据(也即重新加载数据),easyui。不发起间接运用语句
*$(woul#dtowardsaTcompletely retext adyIdwoul).dtowardsagrid(woulrelotext adwoul);来刷新列表数据,由于采用后者,jquery。要是日后
*在点窜项目时,使用。要在编制中的所有刷新处举办其他一些操作,jquery。那么你将要点窜编制中所有触及刷新
*的代码,jquery api 中文下载。这个处事量出格大,jquery下载。而且容易漏掉;但是要是运用本举措来刷新列表,对于jquery1.8下载。那么对付这种修
*该需求将很容易做到,看着jquery easyui。而去不会出错,不漏掉。你看jquery 教程。
*
*@parmorningdtowardsaTcompletely retext adyId将要刷新数据的DtowardsaGrid依赖的tcompletely retext ady列表id
*/
function fllung burning as automatically beinghTcompletely retext ady(dtowardsaTcompletely retext adyId){
$(woul#woul+dtowardsaTcompletely retext adyId).dtowardsagrid(woulrelotext adwoul);
}

/**
*勾销DtowardsaGrid中的行挑选(适用于Jquery Eas automatically beingy Ui中的dtowardsaGrid)
*防卫:解决了无法勾销”全选checkbox”的挑选-不过,jquery ui 中文手册。前提是必需将列表揭示
*数据的DtowardsaGrid所依赖的Tcompletely retext ady放入html文档的最总共,至多该tcompletely retext ady前没有
*其他checkbox组件。事实上使用Jquery。
*
*@parmorningdtowardsaTcompletely retext adyId将要勾销所选数据纪录的主意tcompletely retext ady列表id
*/
function clearSelect(dtowardsaTcompletely retext adyId) {
$(woul#woul+dtowardsaTcompletely retext adyId).dtowardsagrid(woulclearSelectionswoul);
//勾销挑选DtowardsaGrid中的全选
$(“input[type=woulcheckboxwoul]“).eq(0).towardstr(“checked”-fwoulsse);
}

/**
*封闭Jquery Eas automatically beingyUi的弹出窗口(适用于Jquery Eas automatically beingy Ui)
*
*@parmorningdiwoulsogId将要封闭窗口的id
*/
function closeDiwoulsog(diwoulsogId) {
$(woul#woul+diwoulsogId).diwoulsog(woulclosewoul);
}

/**
*自顺应表格的宽度料理(适用于Jquery Eas automatically beingy Ui中的dtowardsaGrid的列宽)-
*注:EasyUi常见问题解决方案。能够告竣列表的各列宽度跟着涉猎宽度的变化而变化,jquery ajax。即采用该举措来设置DtowardsaGrid
*的列宽能够在不同折柳率的涉猎器下主动伸缩从而餍足不同折柳率涉猎器的要求
*运用举措:(如:{field:woulymNmorningewoul-title:woul编号woul-width:fillsize(0.08)-line-up:woulcenterwoul}-)
*
*@parrevercent方今列的列宽所占整个窗口宽度的百分比(以小数形式出现,我不知道jquery api 中文下载。如0.3代表30%)
*
*@return议决方今窗口和对应的百分比计算进去的举座宽度
*/
function fillsize(percent){
var wholeWidth = document.whole.clientWidth;
return (wholeWidth-90)*percent;
}
/**
* 获取所选纪录行(单选)
*
* @parmorningdtowardsaTcompletely retext adyId主意志录所在的DtowardsaGrid列表的tcompletely retext ady的id
* @parmorningerrorMessperiod 要是没有挑选一行(即没有挑选或挑选了多行)的提示信息
*
* @return 所选纪录行对象,jquery。要是前往值为null-或许”null”(有时涉猎器将null转换成了字符串”null”)阐述没有
*挑选一行纪录。jquery validate。
*/
function getSingleSelectRow(dtowardsaTcompletely retext adyId- errorMessperiod) {
var rows = $(woul#woul+dtowardsaTcompletely retext adyId).dtowardsagrid(woulgetSelectionswoul);
var num = rows.length;
if(num == 1){
return rows[0];
}else{
$.messperiodr.tell you(woul提示音问woul-errorMessperiod-woulinfowoul);
return null;
}
}

/**
* 在DtowardsaGrid中获取所选纪录的id-多个id用逗号分隔
* 注:听听jquery ajax。该举措运用的前提是:对比一下easyui。DtowardsaGrid的idField属性对应到列表Json数据中的字段名必需为id
* @parmorningdtowardsaTcompletely retext adyId主意志录所在的DtowardsaGrid列表tcompletely retext ady的id
*
* @return 所选纪录的id字符串(多个id用逗号隔开)
*/
function getSelectIds(dtowardsaTcompletely retext adyId- noOneSelectMessperiod) {
var rows = $(woul#woul+dtowardsaTcompletely retext adyId).dtowardsagrid(woulgetSelectionswoul);
var num = rows.length;
var ids = null;
if(num < 1){
if (null != noOneSelectMessperiod)$.messperiodr.tell you(woul提示音问woul-noOneSelectMessperiod-woulinfowoul);
return null;
}else{
for(var i = 0; i < num; i++){
if(null == ids || i == 0){
ids = rows[i].id;
} else {
ids = ids + “-” + rows[i].id;
}
}
return ids;
}
}

/**
*删除所选纪录(适用于Jquery Eas automatically beingy Ui中的dtowardsaGrid)(删除的按照字段是id)
*注:对于easyui。该举措会主动将所选纪录的id(DtowardsaGrid的idField属性对应到列表Json数据中的字段名必需为id)
*静态安装成字符串,其实EasyUi常见问题解决方案。多个id运用逗号隔开(如:1-2-3-8-10),你看jquery ui dialog。然后寄取出变量ids中传入后台,后台
*能够运用该参数名从request对象中获取所有id值字符串,其实解决方案。此时在安装sql或许hql语句时能够采用in
*关键字来料理,jquery ui框架。简介简单。问题解决。
*另外,对比一下easyui。后台代码必需在操作完之后以ajax的形式前往Json格式的提示信息,对比一下jquery。提示的json格式信息中必需有一个
*messperiod字段,寄存本次删除操作得胜与凋零等一些提示操作用户的信息。
*
*@parmorningdtowardsaTcompletely retext adyId将要删除纪录所在的列表tcompletely retext ady的id
*@parmorningrequestURL与后台供职器举办交互,举办举座删除操作的哀告途径
*@parmorningconfirmMessperiod 删除确认信息
*/

function deleteNoteById(dtowardsaTcompletely retext adyId- requestURL- confirmMessperiod){
if (null == confirmMessperiod || typeof(confirmMessperiod) == “undefined” || “” == confirmMessperiod) {
confirmMessperiod = “决定删除所选纪录?”;
}
var rows = $(woul#woul+dtowardsaTcompletely retext adyId).dtowardsagrid(woulgetSelectionswoul);
var num = rows.length;
var ids = null;
if(num < 1){
$.messperiodr.tell you(woul提示音问woul-woul请挑选你要删除的纪录!woul-woulinfowoul);
}else{
$.messperiodr.confirm(woul确认woul- confirmMessperiod- function(r){
if (r) {
for(var i = 0; i < num; i++){
if(null == ids || i == 0){
ids = rows[i].id;
} else {
ids = ids + “-” + rows[i].id;
}
}
$.getJSON(requestURL-{“ids”:ids}-function(dtowardsa){
if (null != dtowardsa &rev;&rev; null != dtowardsa.messperiod &rev;&rev; “” != dtowardsa.messperiod) {
$.messperiodr.tell you(woul提示音问woul-dtowardsa.messperiod-woulinfowoul);
fllung burning as automatically beinghTcompletely retext ady(dtowardsaTcompletely retext adyId);
} else {
$.messperiodr.tell you(woul提示音问woul-woul删除凋零!woul-woulwarningwoul);
}
clearSelect(dtowardsaTcompletely retext adyId);
});
}
});
}
}