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. Image for the cookie policy date

Best example for multiple nested tables at same level?

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

14 Replies

AD Administrator Syncfusion Team January 3, 2007 11:09 AM UTC

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


JH John H January 3, 2007 11:18 AM UTC

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


AD Administrator Syncfusion Team January 3, 2007 12:21 PM UTC

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


JH John H January 3, 2007 01:32 PM UTC

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


AD Administrator Syncfusion Team January 4, 2007 09:49 AM UTC

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


JH John H January 4, 2007 11:12 AM UTC

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


AD Administrator Syncfusion Team January 4, 2007 11:57 AM UTC

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);


JH John H January 4, 2007 01:16 PM UTC

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



JH John H January 5, 2007 10:43 AM UTC

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


AD Administrator Syncfusion Team January 5, 2007 11:15 AM UTC

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


JH John H January 5, 2007 11:30 AM UTC

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


AD Administrator Syncfusion Team January 5, 2007 01:45 PM UTC

Hi John,

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

Thanks for using Syncfusion Products.

Best Regards,
Haneef


JH John H January 5, 2007 04:17 PM UTC

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


AD Administrator Syncfusion Team January 8, 2007 04:01 AM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon