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使用技巧总结的更多相关文章

  1. jQuery Mobile 和 Kendo UI 的比较(转)

    jQuery Mobile 和 Kendo UI 的比较 转自 https://www.oschina.net/translate/jquery-mobile-versus-kendo-ui?cmp ...

  2. 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 ...

  3. Web UI开发神器—Kendo UI for jQuery数据管理网格编辑操作

    Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...

  4. Web UI开发速速种草—Kendo UI for jQuery网格编辑操作概述

    Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...

  5. 数据管理必看!Kendo UI for jQuery过滤器的全球化

    Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...

  6. 数据管理必看!Kendo UI for jQuery过滤器状态保持

    Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...

  7. jQuery数据管理:Kendo UI过滤器设置运算符

    Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...

  8. 数据管理必看!Kendo UI for jQuery过滤器概述

    Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...

  9. Web界面开发必看!Kendo UI for jQuery编辑功能指南第二弹

    Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...

随机推荐

  1. iOS - 应用程序国际化

    开发的移动应用更希望获取更多用户,走向世界,这就需要应用国际化,国际化其实就是多语言.这篇文章介绍Xcode4.5以后的国际化,包括应用名国际化和应用内容国际化.如果是Xcode4.5之前版本请参考. ...

  2. ubuntu14.04下unix网络编程环境的配置

    建议 unpv13e/README看一下,忽略一下内容 ===================================================================== 操作 ...

  3. IE8下String的Trim()方法失效的解决方法

    String的Trim()方法失效,在ie8下是有这样的情况的,解决方法也很简单使用$.trim(str)即可,需要的朋友可以了解下 用jquery的trim()方法,$.trim(str)就可以了.

  4. Word图片显示不完整

    选中图片和上下文字,段落里选择单倍行距,其他行距不行.

  5. MDN > Web technology for developers > HTTP

    The Hypertext Transfer Protocol (HTTP) is an application-layer protocol for transmitting hypermedia ...

  6. client denied by server configuration

    http://blog.csdn.net/fdipzone/article/details/40512229

  7. 全球AI界最值得关注的十位科学家

    全球AI界最值得关注的十位科学家   我们可以看到AI已经从象牙塔里的高冷研究,逐步转换为科技公司.互联网公司的最核心竞争力.AI代表了这时代人类的前沿智慧,也正达到一种科学的极致. 这两天在美国加利 ...

  8. MySQL源码 数据结构hash

    MySQL源码自定义了hash表,因为hash表具有O(1)的查询效率,所以,源码中大量使用了hash结构.下面就来看下hash表的定义: [源代码文件include/hash.h mysys/has ...

  9. 性能量化之cpu

    系统现在很慢”似乎是对系统的性能最常用的抱怨了,但究竟慢到什么程度,如何来界定慢,可能需要对性能进行量化,对于OS来说,大致主要分为cpu,内存,磁盘,网络等组件,对这些维度的性能量化,不但可以更准确 ...

  10. 在Eclipse中安装和使用TFS插件

    在Eclipse中安装插件的方法其实都一样,安装TFS的步骤如下: 下载TFS插件.你可以到微软的下载中心,下载TFS插件TFSEclipsePlugin-UpdateSiteArchive-10.0 ...