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

Best way to represent a multi-dimensional grid (hypercube)?

2 Answers 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 27 Apr 2015, 05:26 PM

Hi there,

Can I represent three-dimensional (i.e. x, y and z axis) data or higher on a single RadGrid?

I see that RadGrid has a hierarchical binding facility (http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/programmatic-hierarchy/defaultvb.aspx) for tables of data in a parent-child relationship.  I don't have that, though.  I just have a set of three-dimensional coordinates and a single value for each one: e.g., f(x,y,z) = value where x, y and z can each take the values {1, 2, ..., 10}.  At the moment I am simply displaying 10 different f(x,y) grids for each value of z; as you can appreciate, this is not ideal, particularly when I need to go higher than three dimensions.

I could probably cannibalise the hierarchical binding demo somehow to show it on one grid; the hierarchical functionality clearly wasn't designed with this in mind, though.  Is there a better way?

All answers gratefully received!

Ed

2 Answers, 1 is accepted

Sort by
0
Ed
Top achievements
Rank 1
answered on 28 Apr 2015, 03:12 PM
Just bumping this back up the list ...
0
Accepted
Konstantin Dikov
Telerik team
answered on 30 Apr 2015, 06:52 AM
Hello Ed,

Since the same question is asked in a regular support ticket (Ticket ID: 930750) from another account, I am just going to paste it here as well:

"I have gone through your requirement, but I have to say that there is no control in our suite that could be used for displaying 3 dimensional data. That said, a hierarchical RadGrid is one possible option for displaying the data for each Z position. Another option that I could suggest is to enable paging on the grid and set the data in such manner, so each page could represent different Z position.

For your convenience, following is a very simple example (with dummy data) that demonstrate paging approach, combined with grouping (to visualize the Z value):

<telerik:RadGrid runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource" AllowPaging="true" PageSize="10" OnColumnCreated="RadGrid1_ColumnCreated">
    <MasterTableView>     
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <GroupByFields>
                    <telerik:GridGroupByField FieldName="Z" />
                </GroupByFields>
                <SelectFields>
                    <telerik:GridGroupByField FieldName="Z" />
                </SelectFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>     
    </MasterTableView>
    <PagerStyle ShowPagerText="false" PageSizeControlType="None"/>
</telerik:RadGrid>

And the code-behind:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("X", typeof(string));
    for (int i = 0; i < 10; i++)
    {
        table.Columns.Add("Y" + i, typeof(string));
    }
    table.Columns.Add("Z", typeof(string));
 
    int currentRow = 0;
    for (int z = 1; z <= 10; z++)
    {
        for (int i = 0; i < 10; i++)
        {
            table.Rows.Add("X" + i);
            for (int y = 0; y < 10; y++)
            {
                table.Rows[currentRow][y + 1] = 5;//some values
            }
 
            table.Rows[currentRow][11] = "Z" + (z - 1);
            currentRow++;
        }
    }      
 
    (sender as RadGrid).DataSource = table;
}
 
protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
{
    if (e.Column.UniqueName == "Z" || e.Column.UniqueName == "Z")
    {
        e.Column.Display = false;
    }
}
"


Best Regards,
Konstantin Dikov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Grid
Asked by
Ed
Top achievements
Rank 1
Answers by
Ed
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or