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.
Unfortunately, activation email could not send to your email. Please try again.

Best example for multiple nested tables at same level?

Thread ID:

Created:

Updated:

Platform:

Replies:

54154 Jan 3,2007 05:04 AM Jan 7,2007 11:01 PM Windows Forms 14
loading
Tags: GridControl
John H
Asked On January 3, 2007 05:04 AM

Hi,
Im looking for an example of how best to implement multiple second level tables, e.g. table1 is master, record 1 of master has subset of table2, record 2 of master has subset of table 3, record 3 of master has subest of table 3 as well, etc.

Many thanks
John

Administrator [Syncfusion]
Replied On January 3, 2007 06:09 AM

Hi John,

One way you can do this by having a custom engine. Derive the GridChildTable in the CustomGroupingEngine and override the GetVisibleCount(), there check for the tablename you want to hide through the ParentTableDescriptor.Name and return 0.

Refer the attached sample for more details.
GGC_HideTable.zip

Best Regards,
Haneef

John H
Replied On January 3, 2007 06:18 AM

Hi Haneef,
Thanks for the example, at first glance it looks like it will do exactly what I want, but after opening a few of the parent nodes the grid starts to corrupt the display, especially when scrolling.

Thanks
John


>Hi John,

One way you can do this by having a custom engine. Derive the GridChildTable in the CustomGroupingEngine and override the GetVisibleCount(), there check for the tablename you want to hide through the ParentTableDescriptor.Name and return 0.

Refer the attached sample for more details.
GGC_HideTable.zip

Best Regards,
Haneef

GGC grid.zip

Administrator [Syncfusion]
Replied On January 3, 2007 07:21 AM

Hi John,

You can handle the TableControl.VerticalScroll event and set Table.TableDirty = true; to refresh the table in a grid. Here is a code snippet.

//Form load..
this.gridGroupingControl1.TableControl.VerticalScroll+=new ScrollEventHandler(TableControl_VerticalScroll);


private void TableControl_VerticalScroll(object sender, ScrollEventArgs e)
{
GridTableControl tc = sender as GridTableControl;
tc.BeginUpdate();
tc.Table.TableDirty = true;
tc.EndUpdate(true);
}

Best Regards,
Haneef

John H
Replied On January 3, 2007 08:32 AM

Hi Haneef,
Still seeing the problem, although slightly different. Another screenshot attached. I have checked and TableControl_VerticalScroll is definitely being called.

Thanks

>Hi John,

You can handle the TableControl.VerticalScroll event and set Table.TableDirty = true; to refresh the table in a grid. Here is a code snippet.

//Form load..
this.gridGroupingControl1.TableControl.VerticalScroll+=new ScrollEventHandler(TableControl_VerticalScroll);


private void TableControl_VerticalScroll(object sender, ScrollEventArgs e)
{
GridTableControl tc = sender as GridTableControl;
tc.BeginUpdate();
tc.Table.TableDirty = true;
tc.EndUpdate(true);
}

Best Regards,
Haneef

GGC grid2.zip

Administrator [Syncfusion]
Replied On January 4, 2007 04:49 AM

Hi John,

You can handle the TableControlTopRowIndexChanged event and refresh the client rectangle using the Invalidate method. Here is a code snippet to show this.

private void gridGroupingControl1_TableControlTopRowChanged(object sender, GridTableControlRowColIndexChangedEventArgs e)
{
Rectangle rect = (sender as GridGroupingControl).ClientRectangle;
e.TableControl.Invalidate(rect,true);
}

Best Regards,
Haneef

John H
Replied On January 4, 2007 06:12 AM

Hi Haneef,

There isn't a GGC.TableControlTopRowIndexChanged event.
There isn't a GGC.TableControl.TopRowIndexChanged event.
But there is a GGC.TableControl.TopRowChanged event, but that only supports a GridRowColIndexChangedEventArgs as an arg so e.TableControl doesn't exist.

Sorry to be a pain, but could you update the GGC_HideTable example you posted so that it scrolls correctly with multiple second level tables?

Thanks
John

Administrator [Syncfusion]
Replied On January 4, 2007 06:57 AM

Hi John,

Sorry for the inconvenience caused. Use the Invalidate method to refresh the grid's ClientArea in the TableControlTopRowChanged event. Please try the sample and let me know if this helps.

ModifiedGGC_HideTable.zip

Best Regards,
Haneef

Note:
this.gridGroupingControl1.TableControlTopRowChanged +=new GridTableControlRowColIndexChangedEventHandler(gridGroupingControl1_TableControlTopRowChanged);

John H
Replied On January 4, 2007 08:16 AM

Hi Haneef,
Yeah that was the best I could come up with too, but if you open most of the nodes and scroll you can see the data jumping up and down alot, which isn't ideal. :(

Thanks
John


John H
Replied On January 5, 2007 05:43 AM

Hi Haneef,
Unfortunately even with your latest example Im still seeing some screen corruptions, I have attached a screenshot.
Using your example, set gridGroupingControl1.TableOptions.ListBoxSelectionMode = MultiExtended;
Open all the nodes from bottom up to 1.
select the first parent node.
Multi select at least 1 row from each child table.
Scroll the grid to the bottom, and then back to the top again.
Select the first parent node again.
The child nodes are not repainted, even though they are no longer selected. So moving another window partially over the top of the grid and off again, you can see a partial repaint of the grid and it looks terrible.
Also, selecting child rows from the second parent node are not painted.

Im beginning to think that maybe the GGC isn't actually capable of solving this requirement, let me know what you think.

Thanks
John

GGC grid3.zip

Administrator [Syncfusion]
Replied On January 5, 2007 06:15 AM

Hi John,

Thanks for you patience.

You can derive a GridChildTable as follows. This will give the result you need:

public class GroupingChildTable : GridChildTable, IGridGroupOptionsSource
{
public GroupingChildTable(Element parent):base(parent)
{}
public override int GetVisibleCount()
{
if( GetTableVisible())
return base.GetVisibleCount();
return 0;
}
public override double GetYAmountCount()
{
if( GetTableVisible())
return base.GetYAmountCount();
return 0;
}
public override double GetVisibleCustomCount()
{
if( GetTableVisible())
return base.GetVisibleCustomCount();
return 0;
}
private bool GetTableVisible()
{
if( this != null && this.Category != null
&& this.Category.ToString() != string.Empty)
{
if( int.Parse(this.Category.ToString())%2 == 0 )
{
if(this.ParentTableDescriptor.Name == "FirstChildTable")
return false;
}
else
{
if(this.ParentTableDescriptor.Name == "SecondChildTable")
return false;
}
}
return true;
}
}

Please refer to the modified attached sample for implementation.
CustomizedNestedTable.zip

Let me know if this helps.

Best Regards,
Haneef

John H
Replied On January 5, 2007 06:30 AM

Hi Haneef,
Thank you for your latest example, it works perfectly now, and after I enabled multi select and custom background selection color its still working perfectly. I now just need to review your code to workout how the custom engine actually works! ;-)

I would suggest that you add this example to your KB on how to implement multiple second level tables in a GGC.

Thanks again for all your time and effort on this.

Regards
John


>Hi John,

Thanks for you patience.

You can derive a GridChildTable as follows. This will give the result you need:

public class GroupingChildTable : GridChildTable, IGridGroupOptionsSource
{
public GroupingChildTable(Element parent):base(parent)
{}
public override int GetVisibleCount()
{
if( GetTableVisible())
return base.GetVisibleCount();
return 0;
}
public override double GetYAmountCount()
{
if( GetTableVisible())
return base.GetYAmountCount();
return 0;
}
public override double GetVisibleCustomCount()
{
if( GetTableVisible())
return base.GetVisibleCustomCount();
return 0;
}
private bool GetTableVisible()
{
if( this != null && this.Category != null
&& this.Category.ToString() != string.Empty)
{
if( int.Parse(this.Category.ToString())%2 == 0 )
{
if(this.ParentTableDescriptor.Name == "FirstChildTable")
return false;
}
else
{
if(this.ParentTableDescriptor.Name == "SecondChildTable")
return false;
}
}
return true;
}
}

Please refer to the modified attached sample for implementation.
CustomizedNestedTable.zip

Let me know if this helps.

Best Regards,
Haneef

Administrator [Syncfusion]
Replied On January 5, 2007 08:45 AM

Hi John,

Thanks for your update. Surely we will add this sample in our KnowledgeBase list.

Thanks for using Syncfusion Products.

Best Regards,
Haneef

John H
Replied On January 5, 2007 11:17 AM

Hi Haneef,
Another related question for you, is there a way to hide the child table column headers if no rows exist for it?

Thanks
John

Administrator [Syncfusion]
Replied On January 7, 2007 11:01 PM

Hi John,

Try checking the FilterRecords.Count property in the GetTableVisible method. Here is a code snippet to show this.

private bool GetTableVisible()
{
if( this != null && this.Category != null
&& this.Category.ToString() != string.Empty)
{
if( int.Parse(this.Category.ToString())%2 == 0 )
{
if(this.ParentTableDescriptor.Name == "FirstChildTable")
return false;
}
else
{
if(this.ParentTableDescriptor.Name == "SecondChildTable")
return false;
}
}
if( this.FilteredRecords != null && this.FilteredRecords.Count == 0 )
return false;
return true;
}

Please refer to the modified attached sample for more details.
ModifiedCustomizedNestedTable.zip

Best Regards,
Haneef

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.

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.

;