一时无事,就用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. 死亡的协议--- Pieter Hintjens (ZeroMQ作者)

    过去几年中用zeromq写过几个系统系统.对ZeroMQ强大和灵活印象非常深刻.在阅读zeromq guide文档时候.发现作者整理各种通信模式非常经典和实用,可以作为分布式通信的教科书来看.第一次见 ...

  2. JS读取文件,Javascript之文件操作 (IE)

    一.功能实现核心:FileSystemObject 对象      要在javascript中实现文件操作功能,主要就是依靠FileSystemobject对象. 二.FileSystemObject ...

  3. struts.xml详细配置

    <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quo ...

  4. C:\WINDOWS\system32\config\systemprofile\Desktop引用了一个不可用的位置

    使用迅雷下载压缩文件到桌面时,下载完毕后,如果直接点击"打开文件",则迅雷会报错: C:\WINDOWS\system32\config\systemprofile\Desktop ...

  5. The working copy xxxx needs to be upgraded to Subversion 1.7.

    原因是我在svn是低版本时候checkout的项目 而对方用的版本比我高 然后 我运行这个项目  就要求我  更新 如果我选择   对项目进行upgrade. 当 upgrade后 我的项目就在 现有 ...

  6. iOS App转让流程

    说法一: (1)选择转让APP (2)进入转让界面       点击Continue进入下一步   (3)输入对方的APP ID和Team ID     Apple ID 和 Team ID 可以在m ...

  7. could only be replicated to 0 nodes, instead of 1

    周末机房断电,然后hadoop爆出如题的错误,解决方案就是关闭所有节点的防火墙,相关命令如下: 查看防火墙状态: /etc/init.d/iptables status 暂时关闭防火墙: /etc/i ...

  8. poj 1066 Treasure Hunt

    http://poj.org/problem?id=1066 #include <cstdio> #include <cstring> #include <cmath&g ...

  9. VS2013下的Nmake编译链接成win XP的可执行程序

    nmake下没有指定toolset=vc120_xp等类似物.但是,可以指定Link.exe的链接参数,指定子系统就可以了,/SUBSYSTEM:[WINDOWS | CONSOLE],5.01 5. ...

  10. android 自定义titlebar

    首先,修改标题栏的宽度和背景,在style.xml中添加: <style> <item name="android:background">@drawabl ...