@@ -47,20 +47,6 @@ <h1>Bootstrap Table Examples <a href="https://github.com/wenzhixin/bootstrap-tab
47
47
data-side-pagination ="server "
48
48
data-url ="/examples/bootstrap_table/data "
49
49
data-response-handler ="responseHandler ">
50
- < thead >
51
- < tr >
52
- < th data-field ="state " data-checkbox ="true "> </ th >
53
- < th data-field ="id " data-sortable ="true "
54
- data-footer-formatter ="totalTextFormatter "> ID</ th >
55
- < th data-field ="name " data-sortable ="true " data-editable ="true "
56
- data-footer-formatter ="totalNameFormatter "> Item Name</ th >
57
- < th data-field ="price " data-sortable ="true " data-editable ="true "
58
- data-footer-formatter ="totalPriceFormatter "> Item Price</ th >
59
- < th data-field ="operate "
60
- data-formatter ="operateFormatter "
61
- data-events ="operateEvents "> Item Operate</ th >
62
- </ tr >
63
- </ thead >
64
50
</ table >
65
51
</ div >
66
52
@@ -71,7 +57,49 @@ <h1>Bootstrap Table Examples <a href="https://github.com/wenzhixin/bootstrap-tab
71
57
72
58
$ ( function ( ) {
73
59
$table . bootstrapTable ( {
74
- height : getHeight ( )
60
+ height : getHeight ( ) ,
61
+ columns : [ {
62
+ field : 'state' ,
63
+ checkbox : true
64
+ } , {
65
+ field : 'id' ,
66
+ title : 'ID' ,
67
+ sortable : true ,
68
+ footerFormatter : totalTextFormatter
69
+ } , {
70
+ field : 'name' ,
71
+ title : 'Item Name' ,
72
+ sortable : true ,
73
+ editable : true ,
74
+ footerFormatter : totalNameFormatter
75
+ } , {
76
+ field : 'price' ,
77
+ title : 'Item Price' ,
78
+ sortable : true ,
79
+ editable : {
80
+ type : 'text' ,
81
+ title : 'Item Price' ,
82
+ validate : function ( value ) {
83
+ value = $ . trim ( value ) ;
84
+ if ( ! value ) {
85
+ return 'This field is required' ;
86
+ }
87
+ if ( ! / ^ $ / . test ( value ) ) {
88
+ return 'This field needs to start width $.'
89
+ }
90
+ var data = $table . bootstrapTable ( 'getData' ) ,
91
+ index = $ ( this ) . parents ( 'tr' ) . data ( 'index' ) ;
92
+ console . log ( data [ index ] ) ;
93
+ return '' ;
94
+ }
95
+ } ,
96
+ footerFormatter : totalPriceFormatter
97
+ } , {
98
+ field : 'operate' ,
99
+ title : 'Item Operate' ,
100
+ events : operateEvents ,
101
+ formatter : operateFormatter
102
+ } ]
75
103
} ) ;
76
104
$table . on ( 'check.bs.table uncheck.bs.table ' +
77
105
'check-all.bs.table uncheck-all.bs.table' , function ( ) {
0 commit comments