Skip to content

Commit 444ddb6

Browse files
committed
Grid Editing: Support specifying template property for columns using the regular option, not just data-attributes
1 parent f9afa1c commit 444ddb6

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

grid-spf/grid.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
$.widget( "ui.grid", {
1414
options: {
15-
dataFields: [ "type", "editor", "editorOptions" ],
15+
dataFields: [ "type", "editor", "editorOptions", "template" ],
1616
columns: null,
1717
rowTemplate: null
1818
},
@@ -80,14 +80,9 @@ $.widget( "ui.grid", {
8080
if ( this.options.rowTemplate ) {
8181
return;
8282
}
83-
var headers = this.element.find( "thead th" );
8483
var template = $.map( this.options.columns, function( column, index ) {
85-
// TODO how to specify a custom template using the columns option?
86-
// make columns array-of-objects (optional) to contain all the potential data attributes?
87-
// should then output those when generating the columns
88-
var customTemplate = headers.eq( index ).data( "template" );
89-
if ( customTemplate ) {
90-
return $(customTemplate).html();
84+
if ( column.template ) {
85+
return $( column.template ).html();
9186
}
9287
return "<td class=\"ui-widget-content\">${" + column.property + "}</td>";
9388
}).join( "" );

0 commit comments

Comments
 (0)