Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2732
Hierarchical column synchronization
posted

Hello,

I'm currently converting a windows forms application to the web. The screen I have a problem with contains a hierarchical grid. Each level contains the same columns (14 total) with most columns hidden by default. I want the column chooser functionalitity, column moving and column resizing functionality to synchronize between each level/band. 

In WinForms grid I solved it by subscribing to the "AfterColPosChanged" event.

private void grdTimeInfos_AfterColPosChanged(object sender, AfterColPosChangedEventArgs e)
{
//create and get the Grids Event manager.
GridEventManager gridEventManager = grdTimeInfos.Base.EventManager;

//We need to turn off the AfterColPosChanged event so it wont be called over and over agin when we
//change the position of the bands in the subsequent bands.
gridEventManager.SetEnabled(GridEventIds.AfterColPosChanged, false);

//call the Synchronize method
SynchronizeColumns(e.ColumnHeaders, e.PosChanged);

//Turn the event back on so it will work next time
gridEventManager.SetEnabled(GridEventIds.AfterColPosChanged, true);
}

The synchronizecolumns method handles the 3 possible change events: move, swap and visibliltiy change.

private void SynchronizeColumns(ColumnHeader[] columHeaders, PosChanged positionChanged)
{
switch (positionChanged)
{
case PosChanged.Moved:
//iterate through the Bands Collection

foreach (UltraGridBand band in grdTimeInfos.Base.DisplayLayout.Bands)
{
//make sure that we don't move the same band column that we moved
if (band.Key != columHeaders[0].Band.Key)
{
//for moving, we only need to worry about visiblePostions. So, all we do is
//set the visible position of the grid column in the next band which
//has the same key as ColumnHeader[0]
band.Columns[columHeaders[0].Column.Key].Header.VisiblePosition = columHeaders[0].VisiblePosition;
}
}

break;
case PosChanged.Swapped:
//iterate throug the Bands Collection

foreach (UltraGridBand band in grdTimeInfos.Base.DisplayLayout.Bands)
{
//make sure that we don't swap the same band columns that we just swapped

if (band.Key != columHeaders[0].Band.Key)
{
//use the swap method on the colum to swap the two columns that we get from the
//olumnHeader array.
band.Columns[columHeaders[1].Column.Key].Swap(band.Columns[columHeaders[0].Column.Key]);
}
}

break;
case PosChanged.HiddenStateChanged:
//iterate throug the Bands Collection

foreach (UltraGridBand band in grdTimeInfos.Base.DisplayLayout.Bands)
{
if (band.Key != columHeaders[0].Band.Key)
{
band.Columns[columHeaders[0].Column.Key].Hidden = columHeaders[0].Column.Hidden;
}
}

break;
}
}

Now I want to implement the same functionality in the web interface.
Has something like this be done already, or can you point me to the correct event(s) I need to use to accomplish this?

A challenge!

Kind regards,

Michael 

Parents
No Data
Reply Children