javascript实现silverlight pivotViewer控件

一时无事,就用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,如需了解请转到上一篇= = 

  

时间: 2024-08-02 02:45:38

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

javascript可编辑表格控件 支持全键盘操作

项目中经常会用到表格编辑控件,网上也有不少,但是确实没有完全符合我要求的, 自己写一个吧! 1.该控件支持 数据显示列,文本编辑列,选择列,下拉列,索引列,删除列 六种列类型 2.支持全键盘操作,自定义键位 包括:列焦点切换,行焦点切换,新建行,数据保存(默认 上,下,左,右 键操作) 3.丰富的事件,绝大多数的客户端操作都能触发无刷新后台事件 4.支持统计运算,可自定义运算插件 5.兼容 Ie,chorme,firefox等绝大多数主流浏览器 下载地址:http://files.cnblogs

Silverlight 图表控件 Visifire 常用属性

首要介绍 Visifire 常用属性的设置,用来生成不合样式的图例 设置Chart的属 //设置title的值 // 创建一个题目标对象 Title title = new Title(); // 设置题目标名称 title.Text = titleText; title.Padding = new Thickness(0, 10, 5, 0); // 向图标添加题目 chart.Titles.Add(title); //是否显示3D结果 chart.View3D = view3D; //图表数

javascript翻页小控件paginator

$(container).paginator({  totalrecords : totalRecords,  recordsperpage : recordsPerpage,  pagebtncount : pageBtnCount,  initval : currentPage,  next : '次へ',  prev : '前へ',  first : '',  last : '',  theme : '',  controlsalways : false,  onchange : func

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

1.返回事件 (1.返回silverlight页面,2.返回web页面) private void button_ClickBack(object sender, RoutedEventArgs e)        { 1.返回silverlight页面: this.Content = new BeginControlChart(sTNameClick, strReportDate, false);//增加个参数表名 2.返回web页面 HtmlWindow html = HtmlPage.Wi

实例讲解Silverlight 初始控件如何获得焦点

这个问题本来是在我实际的项目中遇到过的,但这其实是当初项目要求,要求一进入就要使得在用户名那个文字框中聚焦,而不是再用鼠标去点击获得焦点,后来自己费了点时间解决了.本来我没太注意就过去了,没想到在QQ群里也有人问了一样的问题,我想还是写出来,这样大家可以注意一下,可能以后有帮助. 我用一个简单的例子来说明一下吧. 目标:是我要使得在silveright项目中的一个TextBox在不做任何点击操作的同时一开始获得焦点. xaml: 1 <Grid x:Name="LayoutRoot&quo

JavaScript与表单控件

JavaScript与表单控件 1.表单控件 a) 在HTML中表单控件是客户端与服务器进行数据传输的工具,用来收集客户端的信息,并允许客户端的用户以标准格式向服务器提交数据 b) <form name="frmName" action="frmAction" [method="post(默认)/get" [target="targetType"] [enctype=""]></form&

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

一.构造方法ControlChart 1.前台页面控件赋值 //时间下拉框赋值,下拉框赋选定值                for (int ii = DateTime.Today.Year; ii >= 1980; ii--)                {                    string item = string.Format("{0}年", ii.ToString());                    this.dateYear.Items

silverlight visifire控件图表制作——silverlight 静态页面xaml

一.silverlight 静态页面 1. 时间控件:DatePicker ,添加引用: xmlns:sdk="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls", 触发事件:SelectedDateChanged: 2.文本:TextBlock : 3.下拉框:ComboBox,触发事件:SelectionChanged : 4.按钮:Button ,触发事件:Click: 5.图表画布:Gr

silverlight visifire控件图表制作——silverlight 后台方法打印

一.后台方法 1.添加引用:using System.Windows.Printing; 2.全局变量://定义图片和文本打印变量  PrintDocument printImage; 3.构造方法体里: //图片打印对象              printImage = new PrintDocument();            //图片打印事件处理              printImage.PrintPage += new EventHandler<PrintPageEventA