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

Design Decision: "Grid vs. GridDataBoundGrid"

Hi All, We have to make a design decision between using the Syncfusion Grid vs. the SyncFusion GridDataBoundGrid. The following are the things we want to do: 1) Populate the grid using a collection of objects. This collection is a vector which can grow and can shrink like one. It should have the ability to add a new row (i.e. a new object in the collection) 2) We need the grid to be able to support formulae. 3) We need to have split cells in our grid. 4) We need to be able to display the numbers in different unit systems on the grid when the user exercizes the option. These numbers need to be editable in the user-chosen unit system in the cell when displayed. 5) We need to have support for fractions. Any insights based on your experience with using the two controls would be very helpful to us in deciding which one to use. Thanks for your help, Sachin.

6 Replies

AD Administrator Syncfusion Team May 6, 2003 08:09 AM UTC

I sent you a link to the 1.6 beta release that should allow you to handle the fraction editing with the events in the sample that was part of the earlier response. In that sample, instead of the hard-coded algorithms to format and unformat the values, you can use your property descriptor class to provide the proper values. As far as this question goes, if you need teh formula engine it will be easier to have teh data stored in a GridControl's internal GridData object. Then the grid can manage everything in a staright-forward manner. The one problem is how to get the value from your serialized datastore to the grid and then get any changes back to your serialized datastore. One very simple solution would be to use the grid (or the GridData) as your serialized datastore. Then there is no problem at all. The only concern would be who else needs access to this data. If you need a more generic datastore, then getting things into teh grid is very quick if you use teh right techniaue like grid.PopulateValues or something equivalent. The real problem is getting the values back. The simplest solution if it is viable with the size of the data would be to just serialized back out the entire datasource. Then things like moving rows and columns and changed data would automatically be reflected in the saved data. If you cannot do this, then you would have to listed to appropriate events, and modify your datastore accordingly. This can take some work depending on exactly what kind of changes you want reflected back. If you use a GridDataBoundGrid, then the serialization is handled for you, but the formula support will take additional work as no cell specific information other that the cell value is available in a GridDataBoundGrid. So, you would have to manage a FormulaTag collection to allow your GridDataBoundGrid to use formulas.


KL Ken Law May 6, 2003 09:53 AM UTC

In reference to your comment that "no cell specific information other that the cell value is available in a gridDataBoundGrid." Does this mean, for instance, you cannot set the textColor of an individual cell as opposed to an entire column? Does this mean that the cell-level StyleInfo is always overriden by the GridBoundColumns?


AD Administrator Syncfusion Team May 6, 2003 10:42 AM UTC

You can have cell styles that vary from cell to cell in a GridDataBoundGrid. To do so, you have to catch an event (either PrepareViewStyleInfo or Model.QueryCellInfo) to set any cell specific style property other than Text (or CellValue) in a GridDataBoundGrid. You cannot use code like this.gridDataBoundGrid[2,2].BackColor = Color.Red. This is not the case with a non-virtual GridControl which can store cell specific style properties. For such grids, you can use indexers to set cell specific properties.


SB Sachin Bammi May 6, 2003 04:28 PM UTC

We have decided to use the datagrid instead of the GridDataBoundGrid. Thanks Clay for your help. regards, Sachin.


KL Ken Law May 7, 2003 10:21 AM UTC

Thanks - very helpful. I am parsing a "formula" (not a syncfusion formula, but an application-specific one) stored as a text string. If I determine the formula is invalid, I don't want to reject the string, but instead store the fact that it is invalid somewhere in state info, and display the string in red until the user changes it to make it valid. Can you suggest which of the two events you mention would be better for this purpose? > You can have cell styles that vary from cell to cell in a GridDataBoundGrid. > > To do so, you have to catch an event (either PrepareViewStyleInfo or Model.QueryCellInfo) to set any cell specific style property other than Text (or CellValue) in a GridDataBoundGrid. > > You cannot use code like this.gridDataBoundGrid[2,2].BackColor = Color.Red. > > This is not the case with a non-virtual GridControl which can store cell specific style properties. For such grids, you can use indexers to set cell specific properties. > > >


AD Administrator Syncfusion Team May 7, 2003 01:13 PM UTC

The problem is by default, there is no cell-state information stored in a GridDataBoundGrid. So, if you want to remember some cell has an invalid formula and just color it, then you will have to maintain this state information your self. Depending upon the scope of things, you could have some data structure (arraylist, hashtable, or ???) that holds the bad cells. You could manage this list in eitehr CurrentCellValidating or CurrentCellAcceptedChanges. In your event handler, you would verify the formula, and if it is bad, add it to your datastructure (if it is not already there). If it is good, and teh cell is in the datastructure, you would remove it. Then in PrepareViewStyleInfo, you would check each e.RowIndex, e.ColIndex to see if teh cell is invalid (in your data structure), and if it is, you would set e.Style.BackColor to mark it.

Loader.
Live Chat Icon For mobile
Up arrow icon