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.

Databinding and virtual grid functionality

Thread ID:

Created:

Updated:

Platform:

Replies:

12007 Mar 19,2004 06:17 AM Mar 19,2004 04:25 PM Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 19, 2004 06:17 AM

Is there a way to combine some of the functionality of DataBound grids and virtual grids? My data is dynamically modified by various threads (though rather infrequently), so I''d like to take advantage of databinding to keep the grid in sync automatically. However, at any time, the user''s query might use about 10k rows. Only about a dozen will be visible in the grid. I''d like to be able to query the database for the total number and then only load the rows I need from the database into my DataTable? So, I could do something like: DataView dv = new System.Data.DataView(); dv.Table = mytable; dv.Rows = GetNumRows(); //Does a SELECT COUNT(*) FROM my_Table; myGrid.DataSource = dv; myGrid.ViewRowEvent += new ViewRowEventHandler(myGrid_LoadRowEvent); //Loads row in to mytable [Also, is there a way to do this so it works with Grouping. I suppose it would have to use the database''s GROUP BY function since that data isn''t in RAM. This isn''t essential but it would be nice.] Thanks, dan

Administrator [Syncfusion]
Replied On March 19, 2004 06:25 AM

Looking at it further, is the correct idea to override GridModelDataBinder? If so, are there any example of how to do this?

Administrator [Syncfusion]
Replied On March 19, 2004 07:33 AM

To use a derived GridModelDataBinder requires you to derive the grid and the gridmodel as well. Below are some code snippets. In order for the GridGroupingControl to handle grouping, it must have access to all the data. It can only group what it can access.
public class DerDataBoundGrid : GridDataBoundGrid
{
	DerDataBoundGridModel gridModel;
        public DerDataBoundGrid(): base(new DerDataBoundGridModel())
        {
             gridModel = (DerDataBoundGridModel) Model;
        }
        protected override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e)
        {
             base.OnPrepareViewStyleInfo (e);
        }
        protected override GridModelDataBinder CreateBinder()
        {
             return new DerModelDataBinder(gridModel);
        }
}
public class DerModelDataBinder : GridModelDataBinder
{
       DerDataBoundGridModel gridModel;
       public DerModelDataBinder(DerDataBoundGridModel model) : base(model)
       {
            this.gridModel = model;
       }
       CurrencyManager listManager = null;
       CurrencyManager ListManager
       {
             get
             {
                if (this.listManager == null && this.BindingContext != null && this.DataSource != null)
                        return (CurrencyManager) this.BindingContext[this.DataSource, this.DataMember];
                  return this.listManager;
              }
        }
       protected override void QueryCellInfo(GridQueryCellInfoEventArgs e)
       {
             base.QueryCellInfo (e);
       }
       protected override void SaveCellInfo(GridSaveCellInfoEventArgs e)
       {
             base.SaveCellInfo (e);
       }
}
public class DerDataBoundGridModel : GridDataBoundGridModel
{
     public DerDataBoundGridModel()
     {
     }
      protected override void OnQueryCellInfo(GridQueryCellInfoEventArgs e)
     {
           base.OnQueryCellInfo (e);
     }
      protected override void OnSaveCellInfo(GridSaveCellInfoEventArgs e)
     {
          base.OnSaveCellInfo (e);
     }
}

Administrator [Syncfusion]
Replied On March 19, 2004 04:25 PM

So, ignoring Grouping fucntionality, this is how you''d dynamically load rows while still using databinding to handle updates, etc.? Thanks.

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.

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.

;