一时无事,就用js实现了一个silverlight pivotViewer控件来练手。

实现效果:

silverlight PivotViewer说明地址:https://msdn.microsoft.com/zh-cn/library/system.windows.controls.pivot.pivotviewer(v=vs.95).aspx

提前上代码:pivotViewer

主要分了几个类来实现:

PivotViewer:主控件,负责设置属性,组合控件,绑定数据。也是调用的入口

PivotViewerDateTimeProperty、PivotViewerStringProperty:属性绑定,说明属性名称,对应绑定的数据

PivotViewerSelection、PivotViewerDataSourceFilter、PivotViewerPropertyComboBox、PivotViewerViewMode:内部控件,用来显示用户选择的过滤条件、设置过滤条件、设置排序(分组)属性、设置显示模式(表格、图表)

PivotViewerDataSource:处理用户输入的数据源,包括分组、数据排序等。这里的分组功能只做了简单的日期分组和唯一值分组

调用方法很简单,直接模仿的silverlight,所以和silverlight类似:

<div id="panel">
<div class="filter" id="filter"></div>
<div class="selection" id="selection"></div>
<div class="viewMode" id="viewMode"></div>
<div class="sortMode" id="sortMode"></div>
<div class="pivotMain" id="pivotMain"></div>
</div>
#panel { width:100%;height:100%;position:relative;}

    .filter { position:absolute;left:0;width:200px;top:50px; bottom:0px;z-index:1;overflow:auto; }
.selection { position:absolute;left:0;width:100%;top:0;height:50px;z-index:1; }
.viewMode { position:absolute;right:0px;margin-top:10px;height:30px;z-index:2; }
.sortMode { position:absolute;right:300px;margin-top:10px;height:30px;z-index:2; }
.pivotMain { position:absolute;left:200px;right:0;top:50px;bottom:0; } .pivot_wrap { width:100%;height:100%;position:relative;}
.pivot_item { position:absolute;}
.pivot_item {
-webkit-transition: all .5s linear;
-moz-transition: all .5s linear;
-ms-transition: all .5s linear;
transition: all .5s linear;
}
.pivot_groupbg { position: absolute; z-index: -1; height: 100%; }
.pivot_group_title { text-align:center; position: absolute; height: 50px; bottom: 0px; width: 100%; line-height: 50px; }

  

window.onload = function () {
var pivot = new PV.PivotViewer();
pivot.PivotProperties = [new PV.PivotViewerStringProperty(
{ Id: "FName", Options: PV.PivotViewerPropertyOptions.CanFilter, DisplayName: "First Name", Binding: "FirstName" }
), new PV.PivotViewerStringProperty(
{ Id: "LName", Options: PV.PivotViewerPropertyOptions.CanFilter, DisplayName: "Last Name", Binding: "LastName" }
), new PV.PivotViewerDateTimeProperty(
{ Id: "Birthdate", Options: PV.PivotViewerPropertyOptions.CanFilter, DisplayName: "Birthdate", Binding: "Birthdate" }
)]; pivot.ItemTemplates = function (obj) {
return "<div class='pivot_item'>\
<span>"+ obj.FirstName + "</span>\
<span>" + obj.LastName + "</span>\
</div>";
}; pivot.ItemSource = [
{ FirstName: "Albert", LastName: "Rinoff", Birthdate: DateTime(1949, 06, 04), Department: "Sales", Office: "212" },
{ FirstName: "Bertha", LastName: "Smith", Birthdate: DateTime(1968, 07, 12), Department: "Marketing", Office: "324" },
{ FirstName: "Larry", LastName: "Summers", Birthdate: DateTime(1952, 08, 25), Department: "R $amp; D", Office: "150" },
{ FirstName: "Susan", LastName: "Stendy", Birthdate: DateTime(1953, 09, 05), Department: "Marketing", Office: "334" },
{ FirstName: "Mary", LastName: "Gomez", Birthdate: DateTime(1965, 10, 09), Department: "Sales", Office: "210" },
{ FirstName: "Mary", LastName: "Rodrigues", Birthdate: DateTime(1976, 04, 11), Department: "R $amp; D", Office: "140" }
];
pivot.render(document.getElementById("panel"));
};
DateTime = function (year, month, day) {
return new Date(year, month, day);
};

动画用了css3;没有引入jquery,所以用了getElementsByClassName,请使用适当的浏览器打开示例。

思路都是抄的,就不写辣莫详细。大家看看js就好,有没有一种c#的感脚。

用了自己的wod.CLS,如需了解请转到上一篇= = 

  

javascript实现silverlight pivotViewer控件的更多相关文章

  1. Silverlight第三方控件专题

    原文http://www.cnblogs.com/nasa/archive/2008/12/01/1344927.html 这里我收集整理了目前网上silverlight第三方控件的专题,若果有所遗漏 ...

  2. silverlight visifire控件图表制作——silverlight 后台方法页面事件

    1.返回事件 (1.返回silverlight页面,2.返回web页面) private void button_ClickBack(object sender, RoutedEventArgs e) ...

  3. silverlight visifire控件图表制作——silverlight 后台方法ControlChart.xaml.cs

    一.构造方法ControlChart 1.前台页面控件赋值 //时间下拉框赋值,下拉框赋选定值                for (int ii = DateTime.Today.Year; ii ...

  4. 非常精彩的Silverlight 2控件样式

    概述 大家是否觉的现在Silverlight 2提供的默认的控件不能满足自己的要求?好在Silverlight的控件可以运用皮肤,微软Silverlight控件的设计者的主管Corrina开发了几套非 ...

  5. Silverlight之控件应用总结(二)(4)

    [置顶] Silverlight之控件应用总结(二)(4) 分类: 技术2012-04-03 22:12 846人阅读 评论(0) 收藏 举报 silverlightradiobuttonhyperl ...

  6. [置顶] Silverlight之控件应用总结(一)(3)

    [置顶] Silverlight之控件应用总结(一)(3) 分类: 技术2012-04-02 20:35 2442人阅读 评论(1) 收藏 举报 silverlightradiobuttondatat ...

  7. javascript - 可编辑表格控件 支持全键盘操作(无JS框架)

    项目中经常会用到表格编辑控件,网上也有不少,但是确实没有完全符合我要求的, 自己写一个吧! 1.该控件支持 数据显示列,文本编辑列,选择列,下拉列,索引列,删除列 六种列类型 2.支持全键盘操作,自定 ...

  8. [JavaScript]配置日期选择控件

    我选择的日期控件是:bootstrap-datepicker(下载路径:https://github.com/Aymkdn/Datepicker-for-Bootstrap) 比较方便,实用.原来是英 ...

  9. javascript下用ActiveXObject控件替换word书签,将内容导出到word后打印第1/2页

    由于时间比较紧,没多的时候去学习研究上述工具包,现在用javascript操作ActiveXObject控件,用替换word模板中的书签方式解决. 最近有需求将数据导出到word里,然后编辑打印. 想 ...

随机推荐

  1. HTTP协议学习-01

    在学习一门新知识前还是先了解一下这个知识的一点点背景吧! http是属于协议层当中的最顶层的应用层,的面向对象的协议:它于 1990 年提出, 经过几年的使用与发展, 得到不断地完善和扩展. 目前在 ...

  2. python模块之json序列化

    31.序列化:      1.json实现序列化,json.dumps()和json.loads().           >>> s1 = {'k1':'v1','k2':'v2' ...

  3. 优雅降级&渐进增强

    优雅降级(Graceful Degradation) 关注点:最新的浏览器上构建体验很好的WEB应用. 降级:旧版本浏览器提供差强人意的体验,不影响功能的使用. 渐进增强(Progressive En ...

  4. mapreduce (二) MapReduce实现倒排索引(一) combiner是把同一个机器上的多个map的结果先聚合一次

    1 思路:0.txt MapReduce is simple1.txt MapReduce is powerfull is simple2.txt Hello MapReduce bye MapRed ...

  5. 基于fis的前端模块化和工程化方案

    前端构建工具 面对日益复杂的前端环境以及前端技术.node技术的高速发展,前端的开发也越来越工程化,体系化,也就是出现了前端自动化构建工具.他们完成的任务目标基本是: js,css,图片的自动压缩合并 ...

  6. (未解决)android studio:com.android.support:appcompat-v7:22+ Could not found

    错误信息如下: Error:Could not +. Searched in the following locations: https://jcenter.bintray.com/com/andr ...

  7. android 多线程断点续传下载

    今天跟大家一起分享下Android开发中比较难的一个环节,可能很多人看到这个标题就会感觉头很大,的确如果没有良好的编码能力和逻辑思维,这块是很难搞明白的,前面2次总结中已经为大家分享过有关技术的一些基 ...

  8. 值得IT运维人员警示的“一件事儿”

    昨天,一个用户打来了紧急求助电话,并且发了邮件,弄得我当时紧张了一下,以为他们那里又出了什么乱子.用户在电话里说:应用系统性能很差,运行很慢,几近“卡死”的感觉,而且重启了多次应用和数据库服务器,最终 ...

  9. POJ Wormholes 3259

    题目描述: Farmer John 在探索农场的时候 惊奇的发现一些虫洞,虫洞是一个特殊的东西,他是一个单向通道,他能到达虫洞的另一端, 可以穿越到达之前的时间.Farmer John 的由N个农场组 ...

  10. linux有用网址

    正则表达式在线测试 http://tool.oschina.net/regex