File tree Expand file tree Collapse file tree 6 files changed +187
-0
lines changed
YanZhiwei.JavaScript.Utilities Expand file tree Collapse file tree 6 files changed +187
-0
lines changed Original file line number Diff line number Diff line change 531531 <Content Include =" jquery\datatables\1.10.2\plugins\bootstrap\dataTables.bootstrap.css" />
532532 <Content Include =" jquery\datatables\1.10.2\plugins\bootstrap\dataTables.bootstrap.js" />
533533 <Content Include =" jquery\zTree\3.5\zTree_example1.aspx" />
534+ <Content Include =" jqUtilsDemo.aspx" />
534535 <Content Include =" JsDemo.aspx" />
535536 <Content Include =" JsDemo2.aspx" />
536537 <Content Include =" jsUtilsTest.html" />
728729 <Content Include =" bs\v3\css\bootstrap-rtl.css.map" />
729730 <Content Include =" bs\v3\css\bootstrap.css.map" />
730731 <Content Include =" BackHandler\BaseHandler.ashx" />
732+ <Content Include =" data.json" />
731733 <None Include =" jquery\jquery-1.9.1.intellisense.js" />
732734 <Content Include =" jquery\jquery-1.9.1.js" />
733735 <Content Include =" jquery\jquery-1.9.1.min.js" />
13121314 <Compile Include =" jquery\zTree\3.5\zTree_example1.aspx.designer.cs" >
13131315 <DependentUpon >zTree_example1.aspx</DependentUpon >
13141316 </Compile >
1317+ <Compile Include =" jqUtilsDemo.aspx.cs" >
1318+ <DependentUpon >jqUtilsDemo.aspx</DependentUpon >
1319+ <SubType >ASPXCodeBehind</SubType >
1320+ </Compile >
1321+ <Compile Include =" jqUtilsDemo.aspx.designer.cs" >
1322+ <DependentUpon >jqUtilsDemo.aspx</DependentUpon >
1323+ </Compile >
13151324 <Compile Include =" JsDemo.aspx.cs" >
13161325 <DependentUpon >JsDemo.aspx</DependentUpon >
13171326 <SubType >ASPXCodeBehind</SubType >
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "Model" : " Iphone 18" ,
4+ "Name" : " iOS" ,
5+ "Share" : 57.56 ,
6+ "Price Range" : " $800 - $1000" ,
7+ "Brand" : " Apple"
8+ },
9+ {
10+ "Model" : " Nexus 23" ,
11+ "Name" : " Android" ,
12+ "Share" : 24.66 ,
13+ "Price Range" : " $600 - $800" ,
14+ "Brand" : " Samsung"
15+ },
16+ {
17+ "Model" : " Tom-tom" ,
18+ "Name" : " Java ME" ,
19+ "Share" : 10.72 ,
20+ "Price Range" : " $200 - $900" ,
21+ "Brand" : " X Brand"
22+ },
23+ {
24+ "Model" : " Nokia 66610" ,
25+ "Name" : " Symbian" ,
26+ "Share" : 2.49 ,
27+ "Price Range" : " $100 - $500" ,
28+ "Brand" : " Nokia"
29+ },
30+ {
31+ "Model" : " Blackberry" ,
32+ "Name" : " Blackberry" ,
33+ "Share" : 2.26 ,
34+ "Price Range" : " $100 - $1000" ,
35+ "Brand" : " Blackberry"
36+ },
37+ {
38+ "Model" : " Lumia" ,
39+ "Name" : " Windows Phone" ,
40+ "Share" : 1.33 ,
41+ "Price Range" : " $200 - $600" ,
42+ "Brand" : " Nokia"
43+ },
44+ {
45+ "Model" : " iPhone 6" ,
46+ "Name" : " Java ME" ,
47+ "Share" : 10.72 ,
48+ "Price Range" : " $200 - $900" ,
49+ "Brand" : " X Brand"
50+ },
51+ {
52+ "Model" : " Nokia 66610" ,
53+ "Name" : " Symbian" ,
54+ "Share" : 2.49 ,
55+ "Price Range" : " $100 - $500" ,
56+ "Brand" : " Nokia"
57+ },
58+ {
59+ "Model" : " Micromax" ,
60+ "Name" : " Blackberry" ,
61+ "Share" : 2.26 ,
62+ "Price Range" : " $100 - $1000" ,
63+ "Brand" : " Blackberry"
64+ },
65+ {
66+ "Model" : " Lumia " ,
67+ "Name" : " Windows Phone" ,
68+ "Share" : 1.33 ,
69+ "Price Range" : " $200 - $600" ,
70+ "Brand" : " Nokia"
71+ }
72+ ]
Original file line number Diff line number Diff line change 120120 if ( _tableObj . length > 0 ) {
121121 _tableObj [ rowIndex ] [ cellIndex ] . html ( cellValue ) ;
122122 }
123+ } ,
124+ createHeaderRow : function ( id , json ) {
125+ /// <summary>
126+ /// 创建Table Header
127+ /// </summary>
128+ /// <param name="id">table id</param>
129+ /// <param name="json">json数据</param>
130+ /// <returns type="">Table Header Header</returns>
131+ var columnSet = [ ] ;
132+ var headerTr$ = $ ( '<tr/>' ) ;
133+ for ( var i = 0 ; i < json . length ; i ++ ) {
134+ var rowHash = json [ i ] ;
135+ for ( var key in rowHash ) {
136+ if ( $ . inArray ( key , columnSet ) == - 1 ) {
137+ columnSet . push ( key ) ;
138+ headerTr$ . append ( $ ( '<th/>' ) . html ( key ) ) ;
139+ }
140+ }
141+ }
142+ $ ( "#" + id ) . append ( headerTr$ ) ;
143+ return columnSet ;
144+ } ,
145+ createTable : function ( id , json ) {
146+ /// <summary>
147+ /// 创建Table
148+ /// </summary>
149+ /// <param name="id">table id</param>
150+ /// <param name="json">json数据</param>
151+ var columns = this . createHeaderRow ( id , json ) ;
152+ for ( var i = 0 ; i < json . length ; i ++ ) {
153+ var row$ = $ ( '<tr/>' ) ;
154+ for ( var colIndex = 0 ; colIndex < columns . length ; colIndex ++ ) {
155+ var cellValue = json [ i ] [ columns [ colIndex ] ] ;
156+ if ( cellValue == null ) { cellValue = "" ; }
157+ row$ . append ( $ ( '<td/>' ) . html ( cellValue ) ) ;
158+ }
159+ $ ( "#" + id ) . append ( row$ ) ;
160+ }
123161 }
124162 }
125163 jqUtils . Ajax = {
Original file line number Diff line number Diff line change 1+ <% @ Page Language= " C#" AutoEventWireup= " true" CodeBehind= " jqUtilsDemo.aspx.cs" Inherits= " YanZhiwei.JavaScript.Utilities.jqUtilsDemo" %>
2+
3+ <!DOCTYPE html>
4+
5+ <html xmlns =" http://www.w3.org/1999/xhtml" >
6+ <head runat =" server" >
7+ <title >jqUtils Demo</title >
8+ <script src =" jquery/jquery-1.9.1.min.js" type =" text/javascript" ></script >
9+ <script src =" jqUtils.js" type =" text/javascript" ></script >
10+ <script type =" text/javascript" >
11+ $ (document ).ready (function () {
12+
13+ $ .getJSON (" data.json" , function (data ) {
14+ jqUtils .UITable .createTable (' jsonTable' , data);
15+ });
16+ });
17+ </script >
18+ </head >
19+ <body >
20+ <form id =" form1" runat =" server" >
21+ <div style =" margin : 20px auto ; width : 500px ;" >
22+ <table id =" jsonTable" style =" border-collapse : collapse ;" border =" 1" cellpadding =" 5" >
23+ </table >
24+ </div >
25+ </form >
26+ </body >
27+ </html >
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Web ;
5+ using System . Web . UI ;
6+ using System . Web . UI . WebControls ;
7+
8+ namespace YanZhiwei . JavaScript . Utilities
9+ {
10+ public partial class jqUtilsDemo : System . Web . UI . Page
11+ {
12+ protected void Page_Load ( object sender , EventArgs e )
13+ {
14+
15+ }
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments