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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grouping Grid in cache

Thread ID:

Created:

Updated:

Platform:

Replies:

80113 Mar 13,2009 11:02 PM UTC Apr 2,2009 10:53 AM UTC WinForms 12
loading
Tags: GridControl
Vladimir Shcherbina
Asked On March 13, 2009 11:02 PM UTC

Hi All,

We are using GGC version 4.x for our forms. These forms are explored using some tree control, so user can expand various places in the tree and open different grids. For some grids it will take up to 15 seconds in order to open them. This is, because their data retrieval process is expensive. In order to reduce time, we put already opened grids in cache (actually a simple dictionary in C#), so the data retrieval process will occur only first time for every grid. It works fine, but if our grid has related tables (subgrids) the GGC doesn't display them correctly. So, if you expand such table you will see the blank space. This happens only if you put a grid in memory cache but it happens from the very beginning! E.g. the grid was initialized displayed and placed in the dictionary, and its related tables comes blank.
Any idea?


Vladimir Shcherbina
Replied On March 16, 2009 01:07 PM UTC



>Hi All,

We are using GGC version 4.x for our forms. These forms are explored using some tree control, so user can expand various places in the tree and open different grids. For some grids it will take up to 15 seconds in order to open them. This is, because their data retrieval process is expensive. In order to reduce time, we put already opened grids in cache (actually a simple dictionary in C#), so the data retrieval process will occur only first time for every grid. It works fine, but if our grid has related tables (subgrids) the GGC doesn't display them correctly. So, if you expand such table you will see the blank space. This happens only if you put a grid in memory cache. E.g. the grid was initialized displayed and placed in the dictionary, then you switch to another grid, switch back and its related tables comes blank.
Any ideas?




Jisha Joy [Syncfusion]
Replied On March 18, 2009 09:29 AM UTC

Hi Vladimir,

Thank you for using Syncfusion Products.

Could you please provide us a simple sample showing the issue?. It is difficult to identify the problem without seeing it in a live application.

Regards,
Jisha


Vladimir Shcherbina
Replied On March 23, 2009 10:31 PM UTC

Hi Jisha,

I cannot supply the sample yet, but I understand much better a kind of problem. I have GGC with ChildTable and GridEngine. I save my GridEngine into the new m_savedEngine by using initializeFrom. Then, I put my GGC in memory cache (C# Dictionary). When user will switch to another grid, I hide my GGC and fill my GGC with new data. In the time that user switch back to the first GGC, I retrieve my GGC from cache and copy old GGC data from m_savedEngine by using initializeFrom. It work if my GGC hasn't any ChildTable inside, otherwise on subsequent GGC openings, I am getting exception when I try to expand ChildTable. Seems that ChidlTable has disposed engine reference. I saw that it failed in the IsNewUniformChildListRelation method since Engine property is NULL.
I am using SyncFusion 4.2.XX
What is a right approach for GGC caching ?

>Hi Vladimir,

Thank you for using Syncfusion Products.

Could you please provide us a simple sample showing the issue?. It is difficult to identify the problem without seeing it in a live application.

Regards,
Jisha




Jisha Joy [Syncfusion]
Replied On March 24, 2009 06:31 AM UTC

Hi Vladimir,

Thank you for the details.

You need to serialize the GridGroupingControl by means of XML serialization.


Here is the code to save the schema with the "XmlTextWriter" and "WriteXmlSchema".

FileDialog dlg = new SaveFileDialog();
dlg.AddExtension = true;
dlg.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*" ;
if (dlg.ShowDialog() == DialogResult.OK)
{
XmlTextWriter xw = new XmlTextWriter(dlg.FileName, System.Text.Encoding.UTF8);
this.gridGroupingControl1.WriteXmlSchema(xw);
xw.Close();
}


The code to load the schema is performed using the combination of an "XmlReader" and "CreateFromXml" or "ApplyXmlSchema".


FileDialog dlg = new OpenFileDialog();
dlg.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*" ;
if (dlg.ShowDialog() == DialogResult.OK)
{
XmlReader xr = new XmlTextReader(dlg.FileName);
GridEngine engine = GridEngine.CreateFromXml(xr);
if (engine != null)
this.gridGroupingControl1.Engine.InitializeFrom(engine);
xr.Close();
}


You can refer the following sample in our sample browser for more details.

Grid Grouping Samples ----> Serialization----> XML serialization

This sample demonstrates the serialization and deserialization of the schema information using the XML serialization.

The sample also shows how to serialize and deserialize the grid's schema information using the XML serialization. "Serialization" is the process of saving the state of an object by converting it into a stream of bytes. The reverse process of serialization is "deserialization".

Please try this and let me know if this helps.

Regards,
Jisha




Vladimir Shcherbina
Replied On March 24, 2009 07:52 AM UTC

Hi Jisha,

Thanks a lot for your answer. I'll try your solution. The only question is about performance. We want to save time for subsequent GGC openings, should we see any performance gains in case of serialization/deserialization ?
Regards,
Vladimir

>Hi Vladimir,

Thank you for the details.

You need to serialize the GridGroupingControl by means of XML serialization.


Here is the code to save the schema with the "XmlTextWriter" and "WriteXmlSchema".

FileDialog dlg = new SaveFileDialog();
dlg.AddExtension = true;
dlg.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*" ;
if (dlg.ShowDialog() == DialogResult.OK)
{
XmlTextWriter xw = new XmlTextWriter(dlg.FileName, System.Text.Encoding.UTF8);
this.gridGroupingControl1.WriteXmlSchema(xw);
xw.Close();
}


The code to load the schema is performed using the combination of an "XmlReader" and "CreateFromXml" or "ApplyXmlSchema".


FileDialog dlg = new OpenFileDialog();
dlg.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*" ;
if (dlg.ShowDialog() == DialogResult.OK)
{
XmlReader xr = new XmlTextReader(dlg.FileName);
GridEngine engine = GridEngine.CreateFromXml(xr);
if (engine != null)
this.gridGroupingControl1.Engine.InitializeFrom(engine);
xr.Close();
}


You can refer the following sample in our sample browser for more details.

Grid Grouping Samples ----> Serialization----> XML serialization

This sample demonstrates the serialization and deserialization of the schema information using the XML serialization.

The sample also shows how to serialize and deserialize the grid's schema information using the XML serialization. "Serialization" is the process of saving the state of an object by converting it into a stream of bytes. The reverse process of serialization is "deserialization".

Please try this and let me know if this helps.

Regards,
Jisha






Jisha Joy [Syncfusion]
Replied On March 26, 2009 08:51 AM UTC

Hi Vladimir,

Thank you for your update.

Thank you for your update. I have searched our support database for any mention of performace problem with setialization/deserialization and I am not able to find one.

Regards,
Jisha




Vladimir Shcherbina
Replied On March 26, 2009 06:13 PM UTC

Hi Jisha,

I got an exception (see below), when I try to call WriteXmlSchema. Maybe, it is because of MyEngine which is a subclass of GridEngine?
Any help would be greatly appreciated.

System.InvalidOperationException: there was an error generating the XML document
the type MyGrid.MyEngine was not expected. Use XmLinclude or SoapInclude attribute to specify types that are not known statically at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterGridEngine.Write37_GridEngine(String n, String ns, GridEngine o, Boolean isNullable, Boolean needType)
at Microsoft.XmlSerialization.GeneratedAssembly.XmlserializationWriterGridEngine.Write38_GridEngine(Object o)
at
System.Xml.Serialization.XMlserializer.Serialize(XMLWriter writer, Object o, XmlSerializerNamespace, namespaces, String encoding style, String Id)
at
System.XMLSerialization.XMLserializer.Serialize(XMLWriter writer, Object o)
at
SyncFusion.Windows.Forms.Grid.Grouping.GridEngine.WriteXml(XmlWriter xw)
at
SyncFusion.Windows.Forms.Grid.Grouping.GridGroupingControl.WriteXmlSchema(XmlWriter xw)
at
MyGrid.HideGrid()

>Hi Jisha,

Thanks a lot for your answer. I'll try your solution. The only question is about performance. We want to save time for subsequent GGC openings, should we see any performance gains in case of serialization/deserialization ?
Regards,
Vladimir

>Hi Vladimir,

Thank you for the details.

You need to serialize the GridGroupingControl by means of XML serialization.


Here is the code to save the schema with the "XmlTextWriter" and "WriteXmlSchema".

FileDialog dlg = new SaveFileDialog();
dlg.AddExtension = true;
dlg.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*" ;
if (dlg.ShowDialog() == DialogResult.OK)
{
XmlTextWriter xw = new XmlTextWriter(dlg.FileName, System.Text.Encoding.UTF8);
this.gridGroupingControl1.WriteXmlSchema(xw);
xw.Close();
}


The code to load the schema is performed using the combination of an "XmlReader" and "CreateFromXml" or "ApplyXmlSchema".


FileDialog dlg = new OpenFileDialog();
dlg.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*" ;
if (dlg.ShowDialog() == DialogResult.OK)
{
XmlReader xr = new XmlTextReader(dlg.FileName);
GridEngine engine = GridEngine.CreateFromXml(xr);
if (engine != null)
this.gridGroupingControl1.Engine.InitializeFrom(engine);
xr.Close();
}


You can refer the following sample in our sample browser for more details.

Grid Grouping Samples ----> Serialization----> XML serialization

This sample demonstrates the serialization and deserialization of the schema information using the XML serialization.

The sample also shows how to serialize and deserialize the grid's schema information using the XML serialization. "Serialization" is the process of saving the state of an object by converting it into a stream of bytes. The reverse process of serialization is "deserialization".

Please try this and let me know if this helps.

Regards,
Jisha








Jisha Joy [Syncfusion]
Replied On March 27, 2009 08:43 AM UTC

Hi Vladimer,

Please refer to the following sample which demonstrates the custom property in a derived GroupingEngine object and serializes this engine together with the derived object. You can follow same techniques to achieve the intend behavior.

public class GroupingEngine : GridEngine
{
-------------------------
-----------------------------
private static XmlSerializer xmlSerializer;
public static XmlSerializer GetXmlSerializer()
{
if (xmlSerializer == null)
xmlSerializer = new XmlSerializer(typeof(GroupingEngine));

return xmlSerializer;
}

public static GroupingEngine CreateFromXml(XmlReader xr)
{
XmlSerializer serializer = GetXmlSerializer();
object obj = serializer.Deserialize(xr);
xr.Close();
return obj as GroupingEngine;
}
public void WriteXml(XmlWriter xw)
{
XmlSerializer serializer = GetXmlSerializer();
serializer.Serialize(xw, this);
}

public void WriteXml(TextWriter w)
{
System.Xml.XmlWriter xw = new System.Xml.XmlTextWriter(w);
WriteXml(xw);
}



Sample:

http://files.syncfusion.com/support/Grid.Windows/Sample/F80113.zip

Please let me know if this helps.

Regards,
Jisha



Vladimir Shcherbina
Replied On March 27, 2009 07:29 PM UTC

Hi Jisha,

Many thanks for your answer. I'll try it soon. The only question that I have do I need to serialized a whole grid (as in your first example) or just grid engine (as in your second example)?

Best Regards,
Vladimir

>Hi Vladimer,

Please refer to the following sample which demonstrates the custom property in a derived GroupingEngine object and serializes this engine together with the derived object. You can follow same techniques to achieve the intend behavior.

public class GroupingEngine : GridEngine
{
-------------------------
-----------------------------
private static XmlSerializer xmlSerializer;
public static XmlSerializer GetXmlSerializer()
{
if (xmlSerializer == null)
xmlSerializer = new XmlSerializer(typeof(GroupingEngine));

return xmlSerializer;
}

public static GroupingEngine CreateFromXml(XmlReader xr)
{
XmlSerializer serializer = GetXmlSerializer();
object obj = serializer.Deserialize(xr);
xr.Close();
return obj as GroupingEngine;
}
public void WriteXml(XmlWriter xw)
{
XmlSerializer serializer = GetXmlSerializer();
serializer.Serialize(xw, this);
}

public void WriteXml(TextWriter w)
{
System.Xml.XmlWriter xw = new System.Xml.XmlTextWriter(w);
WriteXml(xw);
}



Sample:

http://files.syncfusion.com/support/Grid.Windows/Sample/F80113.zip

Please let me know if this helps.

Regards,
Jisha





Jisha Joy [Syncfusion]
Replied On March 30, 2009 12:07 PM UTC

Hi Vladimir,

Thank you for your update. I think you need to serialize the gridengine alone.

Please try this and let me know if this helps.

Regards,
Jisha


Vladimir Shcherbina
Replied On March 30, 2009 10:18 PM UTC

Hi Jisha,

Unfortunately, it fails (see stack below). It seems that ChildTable has Engine property set to null. In debugger, I can see that child table reference in top area of stack is "disposed". Any ideas?
Best Regards,
Vladimir

((GroupingEngine)(this.gridGroupingControl1.Engine)).InitializeFrom(engine);

The stack trace is:
System.NullReferenceException: Object reference not set to an instance of an object at
Syncfusion.Grouping.Table.IsNewUniformChildListRelation()
at
Syncfusion.Grouping.Table.InitTopLevelGroup()
at
Syncfusion.Grouping.Table.CategorizeElements()
at
Syncfusion.Grouping.Table.OnEnsureInitialized(Object sender)
at
Syncfusion.Grouping.Element.EnsureInitialized(Object sender, Boolean notifyParent)
at
Syncfusion.Grouping.Table.EnsureInitialized(Object sender, Boolean notifyParent)
at
Syncfusion.Grouping.Element.EnsureInitialized(Object sender)
at
Syncfusion.Grouping.Table.get_TopLevelGroup()
at
Syncfusion.Grouping.Table.get_FilteredChildTableOrTopLevelGroup()
at
Syncfusion.Windows.Forms.Grid.Grouping.GridNestedTableControl.get_Currencell()
at
Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.DeactivateCurrentCell(Boolean allowCancel)
at
Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.Table_DisplayElementChanging(Object sender, DisplayElementChangingEventArgs e)
at
Syncfusion.Windows.Forms.Grid.Grouping.GridTableModel.OnDisplayElementChanging( DisplayElementChangingEventArgs e)
at
Syncfusion.Windows.Forms.Grid.Grouping.GridTableModel.Syncfusion.Grouping.ITableEventsTarget.OnDisplayElementChanging(DisplayElementChangingEventArgs e)
at
Syncfusion.Grouping.Table.OnDisplayElementChanging(DisplayElementChangingEventArgs e)
at
Syncfusion.Grouping.Table.RaiseDisplayElementChanging(Element element, Int32 oldCount, Int32 newCount, Boolean repaintElement, Boolean syncCurrentRecordPos, Boolean leaveCurrentRecord, Boolean scroll)
at
Syncfusion.Grouping.Table.Engine_PropertyChanging(Object sender, DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Windows.Forms.Grid.Grouping.GridTable.Engine_PropertyChanging(Object sender, DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Grouping.DescriptorPropertyChangedEventArgsHandler.Invoke(Object sender, DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Grouping.Engine.OnPropertyChanging(DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Windows.Forms.Grid.Grouping.GridEngine.TableDescriptor_PropertyChanging(Object sender, DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Grouping.DescriptorPropertyChangedEventHandler.Invoke(Object sender, DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Grouping.TableDescriptor.OnPropertyChanging(DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Grouping.TableDescriptor.relations_Changing(Object sender, ListPropertyChangedEventArgs e)
at
Syncfusion.Collections.ListPropertyChangedEventHandler.Invoke(Object sender, ListPropertyChangedEventArgs e)
at
Syncfusion.Grouping.RelationDescriptorCollection.OnChanging(ListPropertyChangedEventArgs e)
at
Syncfusion.Grouping.RelationDescriptorCollection.RaisePropertyItemChanging(RelationDescriptor column, DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Grouping.RelationDescriptor.OnPropertyChanging(DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Grouping.RelationDescriptor.RaisePropertyChanging(String name, EventArgs inner)
at
Syncfusion.Grouping.RelationDescriptor.childTableDescriptor_PropertyChanging(Object sender, DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Grouping.DescriptorPropertyChangedEventHandler.Invoke(Object sender, DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Grouping.TableDescriptor.OnPropertyChanging(DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Grouping.TableDescriptor.unboundFields_Changing(Object sender, ListPropertyChangedEventArgs e)
at
Syncfusion.Grouping.FieldDescriptorCollection.RaisePropertyItemChanging(FieldDescriptor field, DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Grouping.FieldDescriptor.OnPropertyChanging(DescriptorPropertyChangedEventArgs e)
at
Syncfusion.Grouping.FieldDescriptor.set_AllowTrimEnd(Boolean value)
at
Syncfusion.Grouping.FieldDescriptor.ResetAllowTrimEnd()
at
Syncfusion.Grouping.FieldDescriptor.InitializeFrom(FieldDescriptor other)
at
Syncfusion.Grouping.FieldDescriptorCollection.InitializeFrom(FieldDescriptorCollection other)
at
Syncfusion.Windows.Forms.Grid.Grouping.GridTableDescriptor.InitializeFrom(TableDescriptor tableDescriptor)
at
Syncfusion.Grouping.RelationDescriptor.InitializeFrom(RelationDescriptor other)
at
Syncfusion.Grouping.RelationDescriptorCollection.InitializeFrom(RelationDescriptor Collection other)
at
Syncfusion.Windows.Forms.Grid.Grouping.GridTableDescriptor.InitializeFrom(TableDescriptor tableDescriptor)
at
Syncfusion.Grouping.Engine.InitializeFrom(Engine other)
at
Syncfusion.Windows.Forms.Grid.Grouping.GridEngineBase.InitilizeFrom(Engine source)
at
Syncfusion.Windows.Forms.Grid.Grouping.GridEngine.InitializeFrom(Engine source)
at
MyEngine.InitializeFrom(Engine source)
....


>Hi Vladimir,

Thank you for your update. I think you need to serialize the gridengine alone.

Please try this and let me know if this helps.

Regards,
Jisha




Jisha Joy [Syncfusion]
Replied On April 2, 2009 10:53 AM UTC

Hi Vladimir,

It is difficult to identify the issue without seeing it in a live application. Could you please provide us a sample which shows the issue?. So that we could analyze the issue here and try to find a better solution soon.

Please let me know if you have any questions.

Regards,
Jisha






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

;