This is a migrated thread and some comments may be shown as answers.

[Solved] Group By expression

3 Answers 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
bjrivera
Top achievements
Rank 1
bjrivera asked on 30 Nov 2010, 10:34 PM

What is the BEST way to group data by an expression within a grid?  I am not looking for a "nested grouping" but grouping of mulitple columns in "one group".  When it appears in the UI, it should appear as "one group" not as a "nested group".  I see in RadGrid for ASP.NET AJAX has GridGroupByExpression.

I am currently achieving the results I need the following way:

Within the MVC View (as shown below) I group by a calculated column "FinancialChargeType" which is of data type string.

<% Html.Telerik().Grid<Main.Areas.BuildingPermit.Models.InquireFee>(Model.Fees)
    .Name("fees")
    .DataKeys(keys =>
    {
        keys.Add(o => o.Fee.BAFeeID);
    })
    .Columns(columns =>
    {
        columns.Bound(o => o.Fee.FeeCategoryDescription).Title("Fee Category").HtmlAttributes(new { @style = "text-align:left;" });
        columns.Bound(o => o.Fee.FeeDescription).Title("Fee Description").HtmlAttributes(new { @style = "text-align:left;" });
        columns.Bound(o => o.Fee.CalculatedDollarAmount).Title("Amount").HtmlAttributes(new { @style = "text-align:right;" });
    })
    .Groupable(grouping => grouping.Groups(groups =>
    {
        groups.Add(c => c.FinancialChargeType);
        //groups.Add(c => c.Transaction.ReceiptNumber);
        //groups.Add(c => c.Transaction.ReceiptDate);
    }))
.DataBinding(dataBinding => dataBinding
    .Server()
     .Select("InquirePermit", "InquirePermit", new { TabIndex = 4 }))
.Render();
%>

The column "FinancialChargeType" value is a concatenation of values from the desired columns I want to group by.  Below is the LINQ to SQL statement:

var fees = (from f in ctx.BAFees
            join tt in ctx.FinancialTransactions on f.FinancialTransactionID equals tt.FinancialTransactionID
            join bp in ctx.BuildingPermits on tt.LMReferenceNumber equals bp.PermitNumber
            where bp.PermitID == PermitID
            select new InquireFee
            {
                 Fee = f,
                 Transaction = tt,
                 TransactionType = tt.FinancialChargeType,
                 FinancialChargeType = string.Format("{0}    Receipt #: {1}  {2}", tt.FinancialChargeType.FinancialChargeTypeDescription, tt.ReceiptNumber, tt.ReceiptDate)
            }).ToList();

The result is the following:

-> Financial Charge Type: Permit Fee - Receipt #: R1030176-3/0001 11/16/2010 11:22:00 AM

I appreciate you time and assistance.  Please advise.

Barbara Rivera

3 Answers, 1 is accepted

Sort by
0
Yitzhak Khabinsky
Top achievements
Rank 1
answered on 01 Dec 2010, 04:48 PM

Yes, it is much needed feature, i.e. grouping by more than one column without nesting.

In addition it would be great to have a new property to give a full control for the appearance of the group row.

The default group row could stay as is - string.Format("{0} : {1}", columnTitle, groupingValue), but should be able to accept any parameters.

May be these features could make it into the SP1 for the Telerik Extensions for ASP.NET MVC Q3 2010?

Regards,
Yitzhak

0
Darrien
Top achievements
Rank 1
answered on 03 Jan 2011, 09:09 PM
I agree with changing the format of the Group Header.  I need to have the "ColumnTitle:" portion removed.  Is there anyway to do this currently?
0
Atanas Korchev
Telerik team
answered on 04 Jan 2011, 08:29 AM
Hi,

 We do not currently support that feature. We have it logged as a feature request and you can vote for it.

All the best,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
bjrivera
Top achievements
Rank 1
Answers by
Yitzhak Khabinsky
Top achievements
Rank 1
Darrien
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or