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

Need the grid to display a pivot data

3 Answers 183 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pams
Top achievements
Rank 1
Pams asked on 28 Nov 2010, 08:56 PM
Hello,
I am using grid to display the data in a pivot manner. The intial data will be in the following format.
Apart from these columns there are many more columns from the source data.
Id  Cat/SubCatGroup TransactionDate Amount
1   Painting   10/04/2010 250
2   Music   09/27/1010 51.75
3   Music   09/27/1010 30
4   Music   09/27/1010 4

What I need to display in the grid is as shown in the  attached file  output format.png I have been trying this since long time. I am using OnNeedDataSource to bind the data.
protected void samplegrid_DataSource(object sender, EventArgs e)
{
//tr is the data (list<t> that contains the data received from the database)
//ToDataTable() is the method which converts the list of objects to datatable
   samplegrid.DataSource = GetInversedDataTable(ToDataTable(tr), "TransactionDate", "CatSubCatName",Amount", "-");
}


//In the GetInversedDataTable()-- I tried to create a datatable with data which will be in the required format

Id            Cat/SubCatGroup            09/27/2010         10/04/2010

1              Painting                                                         250

2              Music                                    51.75

3              Music                                    30          

4              Music                                    4


But here I dont want to display the Id column.
I want the amount value as a hyperlink. When I click particular amount value, I need to collect that Id value at the backend. Based on that value I have to do some action.


Could anyone please suggest me how to proceed.
Urgent pls.
thanks in advance

3 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 02 Dec 2010, 10:45 AM
Hi Pams,

I am sending you a simple example which demonstrates the desired functionality. Please check it out and let me know if it helps you.
Looking forward for your reply.

All the best,
Radoslav
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Pams
Top achievements
Rank 1
answered on 02 Dec 2010, 09:55 PM
Hello,
thank you for your reply.
I saw the output from the code which was attached. That is just the pivot form of the normal data. I already was able to get the inverted data from the normal dataset. But my requirement is different.
I had attached the format which I am looking for.
For every record in the datatable, there will be Transaction date and amount and under which category that entry is.
I need to present the summarized data.
Dates as column and, I need to show all the items under one category.
I was able to present the data in the format shown in the following obtained-output attachement. If u see the items under Meals-Breakfast. There are 4 items totally. But it is occupying more space. I need something like the required output attachement

Thank you
0
Radoslav
Telerik team
answered on 07 Dec 2010, 09:02 AM
Hi Pams,

To achieve the desired functionality you could try setting the Width property of the RadGrid:
<telerik:RadGrid runat="server" ID="RadGrid1" Width="800px" AllowPaging="true"  AllowSorting="true" PageSize="6">
    </telerik:RadGrid>

Also you could change the column width individually.For example:
protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        GridColumnCollection columns = RadGrid1.MasterTableView.Columns;
        for (int i = 0; i < columns.Count; i++)
        {
            if (someCondition)
            {
                columns[i].HeaderStyle.Width = Unit.Pixel(200);
                columns[i].HeaderStyle.Wrap = true;
            }
        }
    }

Additionally I suggest you to check out the following forum threads:
http://www.telerik.com/community/forums/aspnet/grid/best-practice-for-grid-and-column-widths.aspx
http://www.telerik.com/community/forums/aspnet-ajax/grid/set-column-width-individually-and-horizontal-line-between-two-rows.aspx

I hope this helps.

Best wishes,
Radoslav
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Pams
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Pams
Top achievements
Rank 1
Share this question
or