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
close icon

Problem initialising GridControl with custom GridModel

I want to override some methods in the GridModel class and thought I could use my own CustomGridModel class in the constructor of my GridControl:

public class GridControlView : GridControl
{
public GridControlView()
: base(new CustomGridModel())
{
}
}

For some reason, by trying to initialise the GridModel myself (rather than passing in null), none of the resulting GridModel properties some be defaulted - I don't see row or column headers for example.

If I also try passing in new GridModel (the same thing occurs. However, if I pass in null to the base class all the properties are as I expect.

I have spent ages looking at the Syncfusion code and as far as I can see the GridControlBase.Model accessor lazily creates the GridModel if none is specified. I simply can not see how this lazily created instance could be initialised differently.

What I don't want to do is default all the properties myself on the GridModel before assigning it - there must be some way the default instance is initialised that I can hook into.

Many thanks,

Jas.


1 Reply

JJ Jisha Joy Syncfusion Team December 12, 2008 09:40 AM UTC

Hi Jas,

The GridModel can be attached and replaced with another object at run-time. The GridControl class will remove any dependencies on the old model and set up a relationship with the new model.

When you replace the model, the grid control will completely refresh and draw the new cell data. Please see the following forum thread for more details.

http://www.syncfusion.com/Support/Forums/message.aspx?&MessageID=50545

Let me know if this helps.

Regards,
Jisha


Loader.
Live Chat Icon For mobile
Up arrow icon