一时无事,就用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. COUNT()函数的使用

    COUNT函数 让我们能够数出在表格中有多少笔资料被选出来.它的语法是: SELECT COUNT("栏位名")        FROM "表格名" 举例来说, ...

  2. POJ 3356(最短编辑距离问题)

    POJ - 3356 AGTC Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Desc ...

  3. python面试题大全

    注:本面试题来源于网络,转载请注明来自http://www.cnblogs.com/goodhacker/p/3366618.html. 1. (1)python下多线程的限制以及多进程中传递参数的方 ...

  4. C#程序设计基础——转义字符

    \’ 单引号 \” 双引号 \\ 反斜杠 \0 空字符 \a 感叹号 \b 退格 \f 换页 \n 换行 \r 回车 \t 水平Tab \v 垂直Tab

  5. HID燈是什么及其工作原理

    HID為HighIntensityDischarge的縮寫,即高壓氣體放電燈,它發光的原理是將12V電壓增壓至23000V的超高電壓,激穿填充在石英管的氙氣,使它發光.然后再將電壓轉成85V左右,穩定 ...

  6. POJ1080 Human Gene Functions(LCS)

    题目链接. 分析: 和 LCS 差不多. #include <iostream> #include <cstdio> #include <cstdlib> #inc ...

  7. HDOJ 1163 Eddy's digital Roots 九余数定理+简单数论

    我在网上看了一些大牛的题解,有些知识点不是太清楚, 因此再次整理了一下. 转载链接: http://blog.csdn.net/iamskying/article/details/4738838 ht ...

  8. LVS安装配置

    LVS安装部署 一.LVS安装(CENTOS) 1.LVS模块ip_vs已经内置在LINUX内核中,一般情况下ip_vs并没有启动,可以通过lsmod | grep ip_vs查看,能够看到信息表示模 ...

  9. (转载)APC支持php5.4了

    (转载)http://www.neatstudio.com/archives/?article-2061.html 时隔一年多,APC终于又更新了,这次更新最大的就是支持PHP5.4:- Add PH ...

  10. bzoj4097 [Usaco2013 dec]Vacation Planning

    Description Air Bovinia is planning to connect the N farms (1 <= N <= 200) that the cows live ...