JQuery Kendo UI使用技巧总结
Kendo UI开发总结 By Gloomyfish on 2013-04-25
在Grid中支持分页刷新:
scrollable: {virtual : true },
在Grid的DataSource中添加分页支持:
serverPaging: true,
serverSorting: true,
serverFiltering: true,
pageSize: 50,
在grid中显示列(显示/隐藏菜单)与过滤支持菜单
filterable: true,
columnMenu: true,
在Grid中隐藏某个指定的列,需要在columns中指定column下面添加:
hidden:true,
使用模板来格式化显示grid中的列数据,给对应列添加模板的代码如下:
template : "#=(value==-1) ? '-' :formatValue(value)#"
对齐显示grid中列文本的代码如下:
attributes:{ style: "text-align: right"}
绑定一个Kendo datasource到kendo.observable对象:
var formVM = kendo.observable({
sources: formDS,
source: null
});
绑定指定的formVM到某个Div元素:
kendo.bind($("#form_div"),formVM);
在页面数据改变时,更新绑定的数据源(DataSource):
formDS.bind("change", function() {
//binds the view-model to the first entryin the datasource
formVM.set("source", this.view()[0]);
});
强制更新form_div中的值:
formVM.set("source.userName", 'gloomyfish');对应的HTML为
<input id="uname"name="uname" data-bind="value: source.userName"/>
启动一个新的浏览器新窗口代码如下:
var left = (screen.width/2)-(800/2);
var top = 0;//(screen.height/2)-(800/2);
// force to open new widows in chrome,IE, FF
window.open("personInfo.html","_blank","resizable=yes, scrollbars=yes,titlebar=yes, width=800, height=800, top="+ top +", left="+ left);
下载grid中选中的所有文件:
var grid = $("#file_grid").data("kendoGrid");
var tr = grid.select(); //gets selected <tr> element
if(tr.length >= 1) {
for(var i=0; i<tr.length;i++) {
var item =grid.dataItem(tr[i]); //gets the dataSourceitem
var fid = item.id;
makeFrame("file/"+ fid +"/fileContent.htm");
}
}
function makeFrame( url )
{
var ifrm = document.createElement( "IFRAME");
ifrm.setAttribute( "style", "display:none;") ;
ifrm.setAttribute( "src", url ) ;
ifrm.style.width = 0+"px";
ifrm.style.height = 0+"px";
document.body.appendChild( ifrm ) ;
}
通过window.location或者window.location.href打开指定URL
同步Grid数据更新,使用如下代码:
grid.dataSource.sync()
或者
myGrid.dataSource.read();
myGrid.refresh();
一个Ajax请求跳转页面的例子:
$.ajax({
url : "openMyInfo",
type : "POST",
data : {userName: name, userId:id },
success : function(jqXHR, textStatus) {
if (jqXHR.jsonResponse.success) {
var url = jqXHR.jsonResponse.message;
window.location=url;
} else {
alert(jqXHR.jsonResponse.message);
}
},
error : function(jqXHR, textStatus, errorThrown) {
alert (errorThrown);
}
});
Kendo UI dropdown list级联菜单刷新:
在父dropdown list上绑定change事件函数:change : onItemChange
在函数中刷新更新子dropdow list的数据源(data source)
var subDDList = $('#subListDiv').data("kendoDropDownList");
subDDList.setDataSource(buildSubList(selectParentId));
上传文件对话框使用
$("#selectedFiles").kendoUpload({
async: {
saveUrl: "myDomain/fileUpload.htm",
autoUpload: true
},
multiple:true, // 支持多个文件上传,
complete: uploadFileComplete, //上传结束以后处理,
error: onError,
cancel: onCancel,
select: onSelect,
success: onSuccess
});
调用代码 $("# selectedFiles ").click();//模拟鼠标双击事件调用,
页面上selectedFileshtml元素为隐藏对象。
禁用IE缓存,在JQuery1.2以上版本支持:
$.ajax({
type:"GET",
url:"static/cache.js",
dataType:"text",
cache:false, // disable cache(禁用IE缓存)
ifModified:true
});
在HTML文件中加上:
<meta http-equiv="Expires"content="0"/>
<meta http-equiv="Cache-Control"content="no-cache"/>
<meta http-equiv="Pragma"content="no-cache"/>
提交数据之后打开在新窗口:
<form action="getMyInfo.htm"method="post" target="_blank">
获取Servlet的真是路径:
request.getSession().getServletContext().getRealPath("/");
实现路径重定向:
((HttpServletResponse)response).sendRedirect(redirectURL);
JS中替换反斜线正则表达式:
var myString = content.replace(/\//g, "\\\\");
或者:var value = value.replace(/\\/g, "whatever");
JQuery中报UncaughtSyntaxError: Unexpected identifier
原因多数是你在前一行少加了分号,或者使用了不恰当的关键字标识,比如
setTimeout(new function(){alert(“Helloworld”);}, 200);
其中new是多余关键字,导致错误。
隐藏页面上DIV内容:
$(my_div_id).css("display","none");
显示它:
$(my_div_id).css("display","");
纯JavaScript方式实现,永远有效的隐藏一个DIV内容的方法:
document.getElementById('myDivID').style.display = 'none';
显示它:
document.getElementById('myDivID').style.display = '';
JQuery Kendo UI使用技巧总结的更多相关文章
- jQuery Mobile 和 Kendo UI 的比较(转)
jQuery Mobile 和 Kendo UI 的比较 转自 https://www.oschina.net/translate/jquery-mobile-versus-kendo-ui?cmp ...
- jQuery UI vs Kendo UI & jQuery Mobile vs Kendo UI Mobile
jQuery UI vs Kendo UI http://jqueryuivskendoui.com/#introduction jQuery Mobile vs Kendo UI Mobile ht ...
- Web UI开发神器—Kendo UI for jQuery数据管理网格编辑操作
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- Web UI开发速速种草—Kendo UI for jQuery网格编辑操作概述
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- 数据管理必看!Kendo UI for jQuery过滤器的全球化
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- 数据管理必看!Kendo UI for jQuery过滤器状态保持
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- jQuery数据管理:Kendo UI过滤器设置运算符
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- 数据管理必看!Kendo UI for jQuery过滤器概述
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
- Web界面开发必看!Kendo UI for jQuery编辑功能指南第二弹
Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...
随机推荐
- LightOj_1408 Batting Practice
题目链接 题意: 击球训练中, 你击中一个球的概率为p,连续击中k1个球, 或者连续击空k2个球, 则训练结束. 求结束训练所击球次数的期望. 思路: 设f[x]为连续击中x个球, 距离结束训练所需要 ...
- 蓝牙音箱bose soundlink mini2链接mac后itunes自动启动的问题解决
1.在应用程序列表中复制一个应用重命名为DoNothingApp.app(非系统应用才可以成功复制) 2.打开terminal执行该命令(执行后需要输入密码),注意mv和iTunes.app后分别有一 ...
- sql server中创建链接服务器图解教程
转自sql server中创建链接服务器图解教程 1.展开服务器对象-->链接服务器-->右击"新建链接服务器" 注意:必须以数据库管理员身份登录(通常也就是sa帐号) ...
- Android 小知识点(持续更新)
①文件保存默认是private权限. ②在layout的xml文件中onClick的方法中包含一个View类型的参数 ③获取项目下files路径:Context.getFilesDir(); ④获取项 ...
- Android UI 设计准则
Design Principles 设计准则 These design principles were developed by and for the Android User Experienc ...
- sort merge join导致temp被爆菊
SQL_ID cqsz37256v36j, child number 1 ------------------------------------- INSERT /*+append*/ INTO T ...
- js常用操作代码
页面前进后退<input type=button value=刷新 onclick="window.location.reload()"><input type= ...
- 【转】Android bluetooth介绍(三): 蓝牙扫描(scan)设备分析
原文网址:http://blog.csdn.net/xubin341719/article/details/38584469 关键词:蓝牙blueZ A2DP.SINK.sink_connect.s ...
- (转载)AS3中的mouseEnabled与mouseChildren
(转载)http://www.cnblogs.com/gongchen/archive/2013/05/09/3069055.html mouseEnabled与mouseChildren都是用来确定 ...
- linux 给用户添加进新的组
给用户user1添加一个新的组group1 usermod -G group1 #给当前登录用户所在组设置为 group1 注意:上面的命令有个问题需要知道,这个操作是重置用户所在组,也就是会让当前用 ...