We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to create a simple pivot grid?

Thread ID:

Created:

Updated:

Platform:

Replies:

99714 Jun 7,2011 07:05 AM UTC Jun 14,2011 05:28 AM UTC WinForms 2
loading
Tags: GridControl
Nihar Ranjan Dalai
Asked On June 7, 2011 07:05 AM UTC

Hi,

I have gone through your Pivot grid sample and it looks good. But, how do I use this control? From what I understand, the user can drag and drop columns onto the pivoting areas to get the grid pivoted. What if I want the pivoting to be done programatically? Can this be achieved? Actually, I have a grid which is bound to an IList data source and I have no knowledge of the columns.

Moreover, if I use this pivot grid in an enterprise application, do you give full support for the component?

Thanks,
Nihar.


Nihar Ranjan Dalai
Replied On June 7, 2011 10:53 AM UTC

Hi,

To be a bit elaborate, I wish to achieve the following things using your Pivot Grid Control. I am using the Pivot Grid Demo present in your sample browser as a reference implementation.

1) I need to have pivoting based on two columns. In the first snapshot attached, it is done on the columns - State and City. The remaining columns should be visible as data rows, only that their values should contain the sum of the individual cells (for all columns), as is shown in the snapshot.

2) I need to do all pivoting programmatically and not by using drag and drop.

3) I need to be able to select all the rows for the category by clicking on the pivoted cell(or on the row header if available).

4) Drop areas are required to be hidden.

5) On clicking a any data cell, whole row should be selected.

6) Single cell selection should be disabled.

Please find attached a snapshot of the expected pivot grid control.

Thanks,
Nihar.



pivoting_expected_b6d5dfa3.zip

Jisha Joy [Syncfusion]
Replied On June 14, 2011 05:28 AM UTC

Hi Nihar,

The pivot grid comprises of the following components.


Display Grid - Displays the data extracted from the underlying database.

Pivot Table Field List - Lists the available fields from the database. Provides a way to add/remove the fields to/from the grid.

Drag-Drop Areas - Serves as a view state of the pivot grid, where you can rearrange the fields by doing a drag-and-drop operation between the row and column label areas.

The following code allows us to display the values as desired to be populated in the main grid. Please refer to the following code in the PivotGridControl.cs file.

void gridFields_CheckBoxClick(object sender, GridCellClickEventArgs e)
{
int rowIndex = e.RowIndex < 2 ? 2 : e.RowIndex;
if (gridFields[rowIndex, 0].Text == "0")
{
//this.gridRows.RowCount++;
//this.gridRows[this.gridRows.RowCount, 0].Text = gridFields[e.RowIndex, 0].Description;
this.gridRows.Rows.InsertRange(this.gridRows.RowCount, 1);
this.gridRows[this.gridRows.RowCount - 1, 0].Text = gridFields[rowIndex, 0].Description;
this.gridRows.Refresh();
PerformLayout(gridRows, null);
}
else
{
int location;
for (int i = 0; i < 4; i++)
{
GridList grid = FindField(gridFields[rowIndex, 0].Description, out location) as GridList;
if (grid != null && location != -1)
{
grid.Rows.RemoveRange(location, location);
PerformLayout(grid, null);
}
}
}
}
You can prevent the cell selection and allow row selection when clicking on the cell by setting the following properties,

gridMainDisplay.ListBoxSelectionMode = SelectionMode.One;
gridMainDisplay.AllowSelection = GridSelectionFlags.None;

Regards,
Jisha



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;