@@ -32,14 +32,9 @@ $.widget( "ui.grid", {
32
32
} ,
33
33
refresh : function ( ) {
34
34
// TODO this code assumes a single tbody which is not a safe assumption
35
- var tbody = this . element . find ( "tbody" ) . empty ( ) ,
36
- template = this . options . rowTemplate ;
37
- // TODO try to replace $.each with passing an array to $.tmpl, produced by this.items.something()
38
- // TODO how to refresh a single row?
39
- $ . each ( this . options . source . toArray ( ) , function ( itemId , item ) {
40
- // TODO use item.toJSON() or a method like that to compute values to pass to tmpl
41
- $ . tmpl ( template , item ) . appendTo ( tbody ) ;
42
- } ) ;
35
+ var tbody = this . element . find ( "tbody" ) . empty ( ) ;
36
+ // TODO how to refresh a single row? -> tmplItem().update()
37
+ $ . tmpl ( this . options . rowTemplate , this . options . source . toArray ( ) ) . appendTo ( tbody ) ;
43
38
tbody . find ( "td" ) . addClass ( "ui-widget-content" ) ;
44
39
this . _trigger ( "refresh" ) ;
45
40
} ,
@@ -82,7 +77,8 @@ $.widget( "ui.grid", {
82
77
return "<td>${" + field + "}</td>" ;
83
78
} ) . join ( "" ) ;
84
79
template = "<tr>" + template + "</tr>" ;
85
- this . options . rowTemplate = template ;
80
+ // compile the template
81
+ this . options . rowTemplate = $ . template ( template ) ;
86
82
}
87
83
} ) ;
88
84
0 commit comments