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

Displaying data in multiple rows inside a radgrid column

6 Answers 651 Views
Grid
This is a migrated thread and some comments may be shown as answers.
saravanan k
Top achievements
Rank 1
saravanan k asked on 25 May 2010, 07:36 AM
Hi all,

         I am having a requirement in which one of the column will hold a list of data for a single entry. I want to display them in the pattern as attached. I dont prefer heirarchial grid for the same since it is making things complex. Please guide me.

Regards,
Saravanan K

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 May 2010, 08:55 AM
Hello Saravanan K,

It is possible to merge the cells having same values by increasing the RowSpan for the cells.
The following forum explains more on this. Please take a look.
Merge cells

-Shinu.
0
saravanan k
Top achievements
Rank 1
answered on 25 May 2010, 11:40 AM
Hi Shinu,
 
            Thanks for the reply. That forum gave me an idea of how to merge cells while rendering the grid. But that is not exactly what i want. My grid data source is a list of objects which inturn has a sub list as a member.

For ex) Consider the attachment, i retrieve a list of objects Maruti Swift, Chevrolet Spark from the business layer which inturn has a string list as member(versions). In the grid i have a column with datafield as versions, and when i try to bind the grid, this particular column displays the text Systems.Collections.Generic.List1[System.String].

I want the values inside the sublist to be displayed. Please help me.

Regards,
Saravanan K
0
Radoslav
Telerik team
answered on 28 May 2010, 10:54 AM
Hello Saravanan,

To achieve the desired functionality you could try the following approach :
On RadGrid.ItemDataBound event handler you could get the related items for the object from the first cell in the row and create a table object which has multiple rows with related string in them. For example:
void Radgrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
        if (e.Item is GridDataItem)
        {
            // The RadGrid's row
            GridDataItem item = e.Item as GridDataItem;
            // Related items (in your case string list as member(versions)).
            List<string> data = new List<string>() { "First", "Second", "Third", "Fourth" };
            Table t = new Table();
            foreach (string s in data)
            {
                TableRow row = new TableRow();
                TableCell cell = new TableCell();
                cell.Text = s;
 
                row.Cells.Add(cell);
                t.Rows.Add(row);
            }
            item["ColumnUniqueName"].Controls.Add(t);
        }
    }

Additionally I am sending you a simple example which demonstrates how to achieve the desired functionality.

I hope this helps.

Best wishes,
Radoslav
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.
0
saravanan k
Top achievements
Rank 1
answered on 02 Jun 2010, 09:02 AM
Hi,
     
        Thanks for the reply.Demo shows binding a seperate list in the ItemDataBound event.

My Object signature is,

string modelName -> to be bounded to a column
List<string> verisionName -> to be extracted in the ItemDataBound event and form the table out of it.
bool stockAvailable -> to be bound to a column

I am retrieving a list of these objects and in the needDataSource method i am assigning,
RadGrid1.DataSource = list<Object>();

Can u please share the few lines, how to refer to the parent object of each row in the ItemDataBound or itemcreated event.

One more option i tried is,

I got the version list as a seperate list and created a radgrid dynamically and assigned its datasource as this list and added it to the template column inside the ItemDataBound event as you suggest above. But when i press refresh or sorting buttons the values are not displayed. Then i tried moving the code to itemcreated but there the problem is i should pass the modelname to get the version list. Since it is itemcreated event i cannot get it from the grid. This again demands accessing the parent object from grid event handlers.

What i am expecting is discussed here http://www.telerik.com/community/forums/winforms/gridview/getting-started-with-gridview-have-a-few-questions.aspx The only difference is it was regarding the windows form gridview. But at the end i can see a reply from the telerik team, that this feature will be present in Q3 2009 release. I am using RadControls for ASP.NET AJAX Q3 2009 pack. If this feature is already there please guide me regarding how to implement it.

Thanks.
Saravanan K



0
Radoslav
Telerik team
answered on 04 Jun 2010, 02:32 PM
Hello –°aravanan,

I am not sure what do you mean by " how to refer to the parent object of each row in the ItemDataBound or ItemCreated event.". From your pervious post I understand that you do not want to use the hierarchical RadGrid. Could you please elaborate a bit more on the desired functionality.

Regarding your second question:

The RadControls for ASP.NET AJAX is different from the RadControls for WinForms. They are different product lines depending on the different technologies. So you could not use the WinForms forums as reference to the functionalities and approaches used in ASP.NET.

Best wishes,
Radoslav
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.
0
saravanan k
Top achievements
Rank 1
answered on 07 Jun 2010, 06:29 AM
Hi,

            I will clearly explain the scenario. I need to show a grid exactly as the attachment in post 1. The structure of the business object i have already posted in post 5 above. In the item data bound event of the grid i am dynamically creating another grid from the sublist in my business object and appending it to the column where i want to show the multiple values. Things went fine. But when i click on the refresh button in the command item the inner grid which i added dynamically disappears. I dont know how the refresh button works, but all other paging and sorting logic hits my item data bound event and my values stays.

Finally i made a work around to solve it, I changed the command name and explicitly written the grid.rebind() in the item command event handler. Now it is working. But i am curious to know what exactly happens when we click the refresh button with command name "rebind".

And regarding my second question, If radcontrols are capable of auto generating columns from the sublists in the object datasource then it would be more useful. Kindly consider this in your future releases.

Thanks,
Saravanan K


Tags
Grid
Asked by
saravanan k
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
saravanan k
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or