AD
Administrator
Syncfusion Team
May 16, 2004 10:16 PM UTC
There is a QueryCellStyleInfo event that you can use to provide values for an unbound column. To save these values back to a special datasource for your unbound values, you can use TableControlCurrentCellValdiating. Here is a little sample.
GGC_QueryCellStyleInfo_2614.zip
AD
Administrator
Syncfusion Team
May 17, 2004 03:13 AM UTC
Thanks, but I''m actually trying to add an unbound extra row up top rather than a column. Thanks.
AD
Administrator
Syncfusion Team
May 17, 2004 03:16 AM UTC
(As the example use case, if there''s an error connecting to the server, I''d like to add an row at the top of the table with a cell covering all the columns explaining the error .)
AD
Administrator
Syncfusion Team
May 17, 2004 05:23 AM UTC
You could show a custom caption row at this point, ie. add your error message to this existing row. And you can use QueryCellStyleInfo to conditionally provide the custom caption. There is a sample in this forum thread. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11530
AD
Administrator
Syncfusion Team
May 17, 2004 05:40 AM UTC
Dan,
you can add additional custom sections to any group. In your specific case, you can check for group.IsTopLevelGroup in the ChildTable.OnInitializeSections method and add that extra section before all other sections.
Once such an extra section class overrides the GetVisibleCount method and returns a value greater than 0 it will appear as Element in the DisplayElements collection. The DisplayElements collection is in sync with rows in the table.
See attached sample. I also did handle QueryCoveredRange so that the whole row is drawn as one large covered cell.
Stefan
GroupCustomers_2088.zip
AD
Administrator
Syncfusion Team
May 17, 2004 11:27 AM UTC
Thank you. I''ll try that.
AD
Administrator
Syncfusion Team
May 18, 2004 06:46 AM UTC
It looks pretty good. I''ve got a few quick questions:
1) It seems to overwrite the header row (and makes it show a summary row which I''ve turned off for the TopLevelGroup). Is there a way around this?
2) Instead of subclassing GridEngineFactoryBase/GridEngine/ChildTable, is it safe to just call this.groupingGring.[something].Sections.Add(new ExtraSection(this)); instead so it can be added/removed at runtime?
Thank you again,
dan
BTW: Some of these assorted samples from the forums are quite useful--you might consider including them with the samples in the distribution.
AD
Administrator
Syncfusion Team
May 18, 2004 07:27 AM UTC
Hi Dan,
1) I am not sure I understand. Do you have steps to see the issue in the example I posted?
2) It should be safe to do that. It''s just that whenever you change the GroupedColumns collection or when the table is set "Dirty", all existing groups will be discared and reinitialized. Also, the TopLevelGroup will be reinitialized. You could listen to the CategorizedRecords event to be notified when that happened and then reinsert the section again.
We try to make all those samples we post here into KB articles. Later we''ll also add some of them to the distribution.
Thanks for the feedback!
Stefan
AD
Administrator
Syncfusion Team
May 19, 2004 12:50 AM UTC
>
1) I am not sure I understand. Do you have steps to see the issue in the example I posted?
Yes -- it looks like it manifests itself in your example as well. The columns of the grid don''t have header cells (CustomerID, CompanyName, ContactName, ...)
If you comment out the line
GridEngineFactory.Factory = new GroupingEngineFactory();
the ExtraSection region obviously doesn''t show up, but the header cells are visible.
Thanks again,
dan
AD
Administrator
Syncfusion Team
May 20, 2004 06:21 PM UTC
(and it seems to take up two rows worth of space, so I suspect it''s somehow covering the header)
AD
Administrator
Syncfusion Team
May 24, 2004 02:51 PM UTC
Hi Dan,
sorry for the late reply. I was travelling the last couple of days.
I looked at the sample I posted above and found that I have a mistake in there:
Replace the line
public class GroupingChildTable : ChildTable
with
public class GroupingChildTable : GridChildTable
That''s why the column headers did not show up in the example.
Stefan
AD
Administrator
Syncfusion Team
May 25, 2004 03:11 PM UTC
Thanks, looks great.
Is there any way to put this inside the scrolling part of the grid (eg in the top-level group, under the header?)
Dan
AD
Administrator
Syncfusion Team
May 25, 2004 06:27 PM UTC
The following code let''s you the ExtraSection below the column headers and before the DetailsSection:
protected override void OnInitializeSections(bool hasRecords, SortColumnDescriptorCollection fields)
{
base.OnInitializeSections(hasRecords, fields);
EndInit();
if (this.IsTopLevelGroup)
{
// Search for Detailssection
for (int n = 0; n < Sections.Count; n++)
{
Section s = this.Sections[n];
if (s is DetailsSection)
{
// Insert before Details
InvalidateCounter();
this.Sections.Insert(n, new ExtraSection(this));
break;
}
}
}
}
The EndInit is kind of "messy" here but necessary. It''s because BeginInit() is called before OnInitilizeSections. While the Sections are in BeginInit mode, you cannot get the Count or Insert.
Stefan
AD
Administrator
Syncfusion Team
May 30, 2004 12:31 AM UTC
Thank you.
How do you find out when this row is selected? My guess is this:
private void itemGrid_TableControlCurrentCellActivated(object sender, GridTableControlEventArgs e)
{
Syncfusion.Grouping.Element element = e.TableControl.Table.;
if(element is ExtraSection)
{
...
}
}
but this seems to thrown a null pointer exception.
Thank you again,
dan
AD
Administrator
Syncfusion Team
May 30, 2004 01:18 AM UTC
(after the dot, it reads CurrentElement, but I suppose that''s immaterial since it doesn''t work...)
AD
Administrator
Syncfusion Team
June 1, 2004 05:54 PM UTC
Dan,
only NestedTable and Record elements can become a current elements in the Table.
But you can check the current cell.
Instead of
Syncfusion.Grouping.Element element = e.TableControl.Table.CurrentElement;
if(element is ExtraSection)
try
Syncfusion.Grouping.Element element = e.TableControl.Table.DisplayElements[e.TableControl.CurrentCell.RowIndex];
if(element is ExtraSection)
Let me know if that didn''t work.
Thanks,
Stefan
AD
Administrator
Syncfusion Team
June 2, 2004 01:50 AM UTC
Works perfectly. Thanks.
AD
Administrator
Syncfusion Team
June 20, 2004 04:12 AM UTC
Is there a way to force the table to update once I''ve added/removed an ExtraSection?
I tried Refresh(), Invalidate(), etc.
Thanks,
dan