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.
Syncfusion Feedback

GridColSizeHelper and GCC with nested datatables (column + sign incorrectly grows)

Thread ID:

Created:

Updated:

Platform:

Replies:

69799 Nov 13,2007 02:22 AM UTC Dec 6,2007 07:59 PM UTC Windows Forms 3
loading
Tags: Grouping
Vinod Tandon
Asked On November 13, 2007 02:22 AM UTC

Im having some trouble using GridColSize Helper and the GCC.

I applied the GridColSizeHelper class on my GCC to Autoextend the leftmost column. The problem is that my GCC contains nested datatables and the parent table will contain an elongated "+" sign in the first column when the form is resized. How can I stop this from happening?

I modified the FrozenColumns sample and attached it to show you what is happening. Just resize the form to see what i mean.

Thanks
-Vinod



GCC_FrozenColumns.zip

haneefm [Syncfusion]
Replied On November 14, 2007 11:55 PM UTC

Hi Vinod,

Instead of using the TableModel.Cols.FrozenCount to get the FrozenCount of the GridTableControl, you need to call the TableControl.GetFirstScrollableCol() method to detect the frozon column in GridTableControl. Below are the modified codes that uses in QueryColWidth event handler in GridColSizeHelper.cs file.

//Line Number 80 : in the GridColSizeHelper.cs file.
case GridColSizeBehavior.FillLeftColumn:
int FrozenColIndex = this.grid.TableControl.GetFirstScrollableCol();
if (e.Index == FrozenColIndex )
{
int leftPiece = this.grid.TableModel.ColWidths.GetTotal(0, FrozenColIndex-1);//this.grid.TableModel.Cols.FrozenCount);
int rightPiece = this.grid.TableModel.ColWidths.GetTotal(FrozenColIndex + 2, this.grid.TableModel.ColCount);
e.Size = this.grid.ClientSize.Width - leftPiece - rightPiece;
e.Handled = true;
}
break;

Please try this and let me know if this helps.

Best regards,
Haneef


Vinod Tandon
Replied On November 15, 2007 02:26 AM UTC

Hi Haneef,

Thanks for your reponse.

While that does fix the + sign from growing incorrectly it also changes the desired behavior of the parent column's lining up to the child and grandchild columns.

I want to still have the Child columns track the width of the parent columns.

The code on line 205 for child columns tracking the parent columns doest work anymore. Is there another way to do this?
My parent/child/grandchild tables will all have the same columns.

--

Furthermore, it also makes "Col 1" which is actually the 3rd column grow/shrink when the form is resized. Ideally I would like to make the ParentName Column ( or column #2) to grow/shrink when the form is resized (and tracked to the child/grandchild columns).

Can I set the visible columns somehow get this disered effect. I really dont need the ParentID/ChildID/GrandChild ID columns (Column #1) to be visible but I will need it to set as a primary key. This would leave then leave the ParentName Column as the left most visible column so that GridColSizeBehavior.FillLeftColumn would perhaps still work. Sorry, I'm still just learning how to use this control. I wanted to fix the column width tracking before I experimented with the visible columns.

Thanks for your help it is much appreciated.

-Vinod


haneefm [Syncfusion]
Replied On December 6, 2007 07:59 PM UTC

Hi Vinod,

Issue 1: Remove the columns in a NestedTable.
>>>>>>
You can use the VisibleColumns collection to remove the column in a grid. Refer the below code.

GridTableDescriptor td = gridGroupingControl1.GetTableDescriptor("ChildTableName");
td.VisibleColumns.Remove("ChildColumnNameHere");

Issue 2: FillLeftColumn in Nested Table.
>>>>>>
You need to handle the QueryColWidth event for nestedtable and set width of the leftcolumn. This code will work for nested tables also.

this.grid.GetTableModel("MyChildTable").QueryColWidth += new GridRowColSizeEventHandler(GridColSizeHelper_QueryColWidth);
this.grid.GetTableModel("MyGrandChildTable").QueryColWidth += new GridRowColSizeEventHandler(GridColSizeHelper_QueryColWidth);

void GridColSizeHelper_QueryColWidth(object sender, GridRowColSizeEventArgs e)
{
switch (_colSizeBehavior)
{
case GridColSizeBehavior.FillLeftColumn:
GridTableModel Model = sender as GridTableModel;
string Name = Model.Table.TableDescriptor.Name;
GridTableControl tc = this.grid.GetTableControl(Name);

int FrozenColIndex = tc.GetFirstScrollableCol();

if (e.Index == FrozenColIndex)
{
int ParentIndentColumn = Name != "MyGrandChildTable" ? 0 : 3;
int indentCols = (Model.GetColumnIndentCount() + ParentIndentColumn) * this.grid.TableOptions.IndentWidth;

int leftPiece = Model.ColWidths.GetTotal(0, FrozenColIndex - 1);
int rightPiece = Model.ColWidths.GetTotal(FrozenColIndex + 1 , Model.ColCount);
e.Size = this.grid.ClientSize.Width - leftPiece - rightPiece - indentCols;
e.Handled = true;
}
break;
default:
break;
}
}

Issue 3: Resizing of ChildColumn
>>>>>>

The reason is that you are setting the TrackWidthOfParentColumn property for childtable in a grid. This property prevents the resizing of the childtable column in a grid.

Please refer to the attached sample for implementation and let me know if this helps.
ModifiedGCC_FrozenColumns.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.

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

;