From 7d100b4663345a67fc4dce74f678960938c3419c Mon Sep 17 00:00:00 2001 From: Mottie Date: Mon, 25 Nov 2013 07:12:45 -0600 Subject: [PATCH] Invalid group class now fails silently. Fixes #438 --- js/widgets/widget-grouping.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/js/widgets/widget-grouping.js b/js/widgets/widget-grouping.js index 1ccc42da..5e010846 100644 --- a/js/widgets/widget-grouping.js +++ b/js/widgets/widget-grouping.js @@ -114,23 +114,26 @@ ts.addWidget({ groupClass = (c.$headers.eq(column).attr('class') || '').match(/(group-\w+(-\w+)?)/g); // grouping = [ 'group', '{word/separator/letter/number/date/false}', '{#/year/month/day/week/time}' ] grouping = groupClass ? groupClass[0].split('-') : ['','letter',1]; // default to letter 1 - currentGroup = cache[rowIndex] ? - ts.grouping[grouping[1]]( c, c.$headers.eq(column), cache[rowIndex][column], /date/.test(groupClass) ? - grouping[2] : parseInt(grouping[2] || 1, 10) || 1, group, lang ) : currentGroup; - if (group !== currentGroup) { - group = currentGroup; - // show range if number > 1 - if (grouping[1] === 'number' && grouping[2] > 1 && currentGroup !== '') { - currentGroup += ' - ' + (parseInt(currentGroup, 10) + - ((parseInt(grouping[2],10) - 1) * (c.$headers.eq(column).hasClass(ts.css.sortAsc) ? 1 : -1))); + // fixes #438 + if (ts.grouping[grouping[1]]) { + currentGroup = cache[rowIndex] ? + ts.grouping[grouping[1]]( c, c.$headers.eq(column), cache[rowIndex][column], /date/.test(groupClass) ? + grouping[2] : parseInt(grouping[2] || 1, 10) || 1, group, lang ) : currentGroup; + if (group !== currentGroup) { + group = currentGroup; + // show range if number > 1 + if (grouping[1] === 'number' && grouping[2] > 1 && currentGroup !== '') { + currentGroup += ' - ' + (parseInt(currentGroup, 10) + + ((parseInt(grouping[2],10) - 1) * (c.$headers.eq(column).hasClass(ts.css.sortAsc) ? 1 : -1))); + } + if ($.isFunction(wo.group_formatter)) { + currentGroup = wo.group_formatter((currentGroup || '').toString(), column, table, c, wo) || currentGroup; + } + $rows.eq(rowIndex).before('' + (wo.group_collapsible ? '' : '') + '' + + currentGroup + ''); } - if ($.isFunction(wo.group_formatter)) { - currentGroup = wo.group_formatter((currentGroup || '').toString(), column, table, c, wo) || currentGroup; - } - $rows.eq(rowIndex).before('' + (wo.group_collapsible ? '' : '') + '' + - currentGroup + ''); } } }