diff options
author | mleibman <michael.leibman@gmail.com> | 2011-03-06 14:15:38 -0800 |
---|---|---|
committer | mleibman <michael.leibman@gmail.com> | 2011-03-06 14:15:38 -0800 |
commit | b192b6c4837df5bfac425cf4fad0568d7cc80a56 (patch) | |
tree | 07ea3f5aa20aa7cef919dd64e0328c9689f15818 /slick.dataview.js | |
parent | 686ad90518d85722544d29eb0a8ad912903f679c (diff) | |
download | SlickGrid-b192b6c4837df5bfac425cf4fad0568d7cc80a56.zip SlickGrid-b192b6c4837df5bfac425cf4fad0568d7cc80a56.tar.gz SlickGrid-b192b6c4837df5bfac425cf4fad0568d7cc80a56.tar.bz2 |
Moved group and totals row handling out of DataView and client pages and into a Slick.Data.GroupItemMetadataProvider responsible for overriding the look and behavior of group and totals rows and providing expand/collapse functionality by acting as a grid plugin (still needs to be registered with the grid on the client page).
Diffstat (limited to 'slick.dataview.js')
-rw-r--r-- | slick.dataview.js | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/slick.dataview.js b/slick.dataview.js index 97ab3b5..cc916b4 100644 --- a/slick.dataview.js +++ b/slick.dataview.js @@ -19,9 +19,14 @@ * * Relies on the data item having an "id" property uniquely identifying it. */ - function DataView() { + function DataView(options) { var self = this; + var defaults = { + groupItemMetadataProvider: new Slick.Data.GroupItemMetadataProvider() + }; + + // private var idProperty = "id"; // property holding a unique row id var items = []; // data by index @@ -54,16 +59,8 @@ var onRowsChanged = new Slick.Event(); var onPagingInfoChanged = new Slick.Event(); - // TODO: move into options - function defaultGroupCellFormatter(row, cell, value, columnDef, dataContext) { - return "<span class='slick-group-toggle " + (dataContext.collapsed ? "collapsed" : "expanded") + "'></span>" + - dataContext.title; - } + options = $.extend(true, {}, defaults, options); - // TODO: move into options - function defaultTotalsCellFormatter(row, cell, value, columnDef, dataContext) { - return (columnDef.groupTotalsFormatter && columnDef.groupTotalsFormatter(dataContext, columnDef)) || ""; - } function beginUpdate() { suspend = true; @@ -242,29 +239,12 @@ // overrides for group rows if (item.__group) { - return { - selectable: false, - focusable: true, - cssClasses: "slick-group", - columns: { - 0: { - colspan: "*", - formatter: defaultGroupCellFormatter, - editor: null - } - } - }; + return options.groupItemMetadataProvider.getGroupRowMetadata(item); } // overrides for totals rows if (item.__groupTotals) { - return { - selectable: false, - focusable: false, - cssClasses: "slick-group-totals", - formatter: defaultTotalsCellFormatter, - editor: null - }; + return options.groupItemMetadataProvider.getTotalsRowMetadata(item); } return null; @@ -556,7 +536,6 @@ }; } - function MinAggregator(field) { var min; |