==================================================================================================
		JS FUNCTIONS.
==================================================================================================
function jsSumValue(value, decimalPlaces) {
    switch (decimalPlaces) {
        case 3:
            return (value == null) ? "0.000" : $.telerik.formatString('{0:#,##0.000}', value);
        case 2:
            return (value == null) ? "0.00" : $.telerik.formatString('{0:#,##0.00}', value);
        case 1:
            return (value == null) ? "0.0" : $.telerik.formatString('{0:#,##0.0}', value);
        case 0:
            return (value == null) ? "0" : $.telerik.formatString('{0:#,##0}', value);
    }
    return (value == null) ? "0.000" : $.telerik.formatString('{0:#,##0.000}', value);
}

var prevBeneAllocationTypeTxt = "";
var prevBillStatusCdTxt = "";
var prevGroupBillStatusCdTxt = "";
var isPrevGroupRow = false;
var filteredRows;
var rwCounter = 0;
function premiumDataListGrid_OnDataBound(e, gridName) {
    var grid = $('#' + gridName).data('tGrid');
    if (grid != null) {
        var data = grid.data;
        if (data != null && grid.$tbody[0] != null && grid.$tbody[0].rows != null) {
            
            filteredRows = jQuery.grep(grid.$tbody[0].rows, function(item, i) {
                return !$(item).hasClass("t-grouping-row");
            });

            for (var i = 0; i < data.length; i++) {
                checkRow(data[i], i);
            }
            //last two subtotal rows:
            while(filteredRows.length > data.length + rwCounter) {
                checkRow(null, (data.length++));
            }
        }
    }
}

function checkRow(dataItem, i) {
    var row;
    while ($(filteredRows[i + rwCounter]).hasClass("t-group-footer")) {
        row = $(filteredRows[i + rwCounter]);
        
        if (isPrevGroupRow) {
            row[0].cells[2].innerHTML = prevBeneAllocationTypeTxt + " " + row[0].cells[2].innerHTML;
            prevBeneAllocationTypeTxt = "";

            row[0].cells[9].innerHTML = prevGroupBillStatusCdTxt;
            prevGroupBillStatusCdTxt = "";

            isPrevGroupRow = false;
        }
        else {
            row[0].cells[9].innerHTML = prevBillStatusCdTxt;
            if (prevGroupBillStatusCdTxt == "")
                prevGroupBillStatusCdTxt = prevBillStatusCdTxt;
            prevBillStatusCdTxt = "";
            isPrevGroupRow = true;
        }
        
        rwCounter += 1;
    }
    if (dataItem != null) {
        isPrevGroupRow = false;
        prevBeneAllocationTypeTxt = (dataItem.BeneAllocationTypeTxt == null) ? "" : dataItem.BeneAllocationTypeTxt;

        if (prevBillStatusCdTxt == "")
            prevBillStatusCdTxt = (dataItem.BillStatusCdTxt == null) ? "" : dataItem.BillStatusCdTxt;
    }
}
==================================================================================================================
		MVC VIEW PAGE
==================================================================================================================
var grid = Html.Telerik();
grid.Grid(Model.ResultTabData.IsSelected == VowTabState.Selected ? (List<ReportPremiumStructure>) ViewBag.PremiumDataList : new List<ReportPremiumStructure>())
    .Name("PremiumDataListGrid_" + Model.ResultTabData.TabId)
    .DataBinding(dataBinding => dataBinding.Ajax().Select("PremiumDataListGridBinding", "PremiumHistory"))
    .Scrollable(c => c.Height("158px"))
    .Groupable(settings => settings.Groups(groups =>
                                               {
                                                   groups.Add(o => o.BeneAllocationTypeTxt);
                                                   groups.Add(o => o.OtherGroupedColumns);
                                               }).Visible(false))
    .ClientEvents(events => events.OnDataBinding(@<text>
                                                      function(e)
                                                      {
                                                      return premiumDataListGrid_OnDataBinding(e, "PremiumDataListGrid_@(Model.ResultTabData.TabId)");
                                                      }
                                                  </text>))
    .ClientEvents(events => events.OnDataBound(@<text>
                                                      function(e)
                                                      {
                                                      return premiumDataListGrid_OnDataBound(e, "PremiumDataListGrid_@(Model.ResultTabData.TabId)");
                                                      }
                                                  </text>))
    .Columns(columns =>
                 {
                     columns.Bound(a => a.LocationId).Visible(false);
                     columns.Bound(a => a.BeneAllocationTypeTxt)
                         .Title(@Resources.Headings.BeneAllocationType)
                         .HeaderHtmlAttributes(new {style = "text-align:center;"})
                         .Aggregate(aggregates => aggregates.Count())
                         .ClientFooterTemplate("Total: ").FooterHtmlAttributes(new {style = "text-align: right; padding-right:5px;"})
                         .ClientGroupFooterTemplate("Sub Total: ").FooterHtmlAttributes(new {style = "text-align: right; padding-right:5px;"});
                     columns.Bound(a => a.ClientBeneName).Title(@Resources.Headings.BenefitName).HeaderHtmlAttributes(new {style = "text-align:center;"});
                     columns.Bound(a => a.OptionName).Title(@Resources.Headings.Option).HeaderHtmlAttributes(new {style = "text-align:center;"}).Visible(Xu.IsVisibleBeneOptions);
                     columns.Bound(a => a.DepTypeName).Title(@Resources.Headings.DepStatus).HeaderHtmlAttributes(new {style = "text-align:center;"});
                     columns.Bound(a => a.RefundTypeCdTxt).Title(@Resources.Headings.RefundType).HeaderHtmlAttributes(new {style = "text-align:center;"}).Visible(Xu.IsVisibleRefundTypeCd);
                     columns.Bound(a => a.BillDateTxt).Title(@Resources.Headings.BillDate).HeaderHtmlAttributes(new {style = "text-align:center;"}).Visible(Xu.IsVisibleMonthToMonth);
                     columns.Bound(a => a.InsuredQty).Visible(Xu.IsVisibleLives)
                         .Title(@Resources.Headings.Lives)
                         .HeaderHtmlAttributes(new {style = "text-align:center;"})
                         .Aggregate(aggregates => aggregates.Sum())
                         .HtmlAttributes(new { style = "text-align: right; padding-right:5px;" })
                         .ClientTemplate("<#= jsSumValue(InsuredQty, 0) #>")
                         .ClientFooterTemplate("<#= jsSumValue(Sum, 0) #>").FooterHtmlAttributes(new { style = "text-align: right; padding-right:5px;" })
                         .ClientGroupFooterTemplate("<#= jsSumValue(Sum, 0) #>").FooterHtmlAttributes(new { style = "text-align: right; padding-right:5px;" });
                     columns.Bound(a => a.VolumeAmt).Visible(Xu.IsVisibleVolume)
                         .Title(@Resources.Headings.Volume)
                         .HeaderHtmlAttributes(new {style = "text-align:center;"})
                         .HtmlAttributes(new {style = "text-align: right; padding-right:5px;"})
                         .Aggregate(aggregates => aggregates.Sum())
                         .ClientTemplate("<#= jsSumValue(VolumeAmt, 3) #>")
                         .ClientFooterTemplate("<#= jsSumValue(Sum, 3) #>").FooterHtmlAttributes(new { style = "text-align: right; padding-right:5px;" })
                         .ClientGroupFooterTemplate("<#= jsSumValue(Sum, 3) #>").FooterHtmlAttributes(new { style = "text-align: right; padding-right:5px;" });
                     columns.Bound(a => a.ContractPremium)
                         .Title(Xu.ContractPremTitle)
                         .HeaderHtmlAttributes(new {style = "text-align:center;"})
                         .HtmlAttributes(new {style = "text-align: right; padding-right:5px;"})
                         .Aggregate(aggregates => aggregates.Sum())
                         .ClientTemplate("<#= jsSumValue(ContractPremium, 3) #>")
                         .ClientFooterTemplate("<#= jsSumValue(Sum, 3) #>").FooterHtmlAttributes(new { style = "text-align: right; padding-right:5px;" })
                         .ClientGroupFooterTemplate("<#= jsSumValue(Sum, 3) #>").FooterHtmlAttributes(new { style = "text-align: right; padding-right:5px;" });
                     columns.Bound(a => a.BillStatusCdTxt).Title(@Resources.Headings.BillStatus).HeaderHtmlAttributes(new {style = "text-align:center;"});
                     columns.Bound(a => a.BillPremium)
                         .Title(@Resources.Headings.BillPrem)
                         .HeaderHtmlAttributes(new {style = "text-align:center;"})
                         .HtmlAttributes(new {style = "text-align: right; padding-right:5px;"})
                         .Aggregate(aggregates => aggregates.Sum())
                         .ClientTemplate("<#= jsSumValue(BillPremium, 3) #>")
                         .ClientFooterTemplate("<#= jsSumValue(Sum, 3) #>").FooterHtmlAttributes(new { style = "text-align: right; padding-right:5px;" })
                         .ClientGroupFooterTemplate("<#= jsSumValue(Sum, 3) #>").FooterHtmlAttributes(new { style = "text-align: right; padding-right:5px;" })
                         .Visible(Xu.IsVisibleBillPremium);
                     columns.Bound(a => a.Claims)
                         .Title(@Resources.Headings.Claims)
                         .HeaderHtmlAttributes(new {style = "text-align:center;"})
                         .HtmlAttributes(new {style = "text-align: right; padding-right:5px;"})
                         .Aggregate(aggregates => aggregates.Sum())
                         .ClientTemplate("<#= jsSumValue(Claims, 3) #>")
                         .ClientFooterTemplate("<#= jsSumValue(Sum, 3) #>").FooterHtmlAttributes(new { style = "text-align: right; padding-right:5px;" })
                         .ClientGroupFooterTemplate("<#= jsSumValue(Sum, 3) #>").FooterHtmlAttributes(new { style = "text-align: right; padding-right:5px;" })
                         .Visible(Xu.IsVisibleClaims);
                     columns.Bound(a => a.LossRatio)
                         .Title(@Resources.Headings.LossRatio)
                         .HeaderHtmlAttributes(new {style = "text-align:center;"})
                         .HtmlAttributes(new {style = "text-align: right; padding-right:5px;"})
                         .Aggregate(aggregates => aggregates.Average())
                         .ClientTemplate("<#= jsSumValue(LossRatio, 1) #>")
                         .ClientFooterTemplate("<#= jsSumValue(Average, 1) #>").FooterHtmlAttributes(new { style = "text-align: right; padding-right:5px;" })
                         .ClientGroupFooterTemplate("<#= jsSumValue(Average, 1) #>").FooterHtmlAttributes(new { style = "text-align: right; padding-right:5px;" })
                         .Visible(Xu.IsVisibleLossRatio);
                 })
    .Render();