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

Business Entity Collection and GDBG

Hi, I need to decide whether should I use traditional DataTable or I can use the collection of my business object. I have the following question. Q1 Can I use the Collection of business entity as “dataSource” for my GDBG? Is there a sample application that using object collection as data source for GDBG? Assuming that we can do that: Q2 How does it work when we change a value in cell, does it get changed in object automatically or we have to write code for this? Q3 What are the griddatacolumn when we are using collection of objects as data source? Q4 Can I use “LayoutColumns” in order to show my record in multiple row? If there is any sample that would be great. Q5 Can I use still “formulas” in my GDBG grid? Does grid update data in object when we change the value of a cell which has formula assign to it? Please do reply! Thanks, Scott

6 Replies

AD Administrator Syncfusion Team August 27, 2005 08:57 PM UTC

1) Yes. Any IList of objects with public properties can be used. Here is a sample using ArrayLists. http://www.syncfusion.com/Support/user/uploads/GDBG_8c7a9cee.zip 2) The default behavior is when you change a value in a cell, the object gets updated when you leave that modified row in the grid. 3) The default behavior is to use the prublic properties of the object in the list. 4) Yes. The sample above does this. 5) You need to do additional work to use excel-like formulas in a GridDataBoundGrid. See this KB. http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=104


AD Administrator Syncfusion Team August 27, 2005 09:58 PM UTC

Thanks, When i say Formulas in GDBG, i mean while i am using a collection of business entity as my " datasource ", can i also use formula at the same time? is there any article where it explain how does GDBG work with other datasource, I mean with collection of business entity. Please do reply!


AD Administrator Syncfusion Team August 27, 2005 10:09 PM UTC

I do not understand what you mean. If you want to add a column in the grid that is a calculation based on the properties in the same row, then you can use a GridGroupingControl. It will allow you to add expressions fields in the same manner you can add DataColumn.Expressions to a column in a DataTable, but it does not require a DataTable. In a GridDataBoundGrid, if your DataSource is not a DataTable, then you will have to do work to support formulas, whether they are excel-like as disused in the kb, or if they are DataColumn.Expressions-type formulas. To support a DataColumn.Expressions type formula, you can add an unbound column, and perform your calculation to populate the unbound column. This sample shows how you can add an unbound column. \Syncfusion\Essential Studio\3.3.0.0\Windows\Grid.Windows\Samples\DataBound\GDBGMultiHeader


RU Rune August 27, 2005 10:13 PM UTC

But when using an IList as a Datasource in stead of a DataTable, there are some grid functionslity that does not work: 1. You can not sort the grid (column sort). 2. You can not add and delete rows. To get this functionality your collections must implement some interfaces (at least IBindingList i think) I eneded up transforming my Business Entities to DataRow objects, and my collections to DataTables on the client by using reflection. And then bind them to the grid. And I transform them back to entities before saving them, using flags to indicate new/update/delete on rows. Rune


AD Administrator Syncfusion Team August 28, 2005 07:28 PM UTC

Rune, what exactly you mean by "adding" and "delete" doesn''t work. which syntax i can''t use? would it be possible for you to provede a simple sample, how did you do it ? thanks,


RU Rune August 28, 2005 09:31 PM UTC

Hi Scott, If you use a DataTable as datasource, you can mark a row and press the "Delete" key to delete the row. And you can add a new row, usually by entering data in a blank row at the bottom. Add, delete and updates will be flagged in the rows in the DataTable without writing any extra code. Add and delete is not supported if the datasource is an ArrayList. You can see one way to implement add/delete in this sample: http://www.syncfusion.com/faq/winforms/search/818.asp This sample uses the standard .NET DataGrid, and buttons for add and delete. Another way is to implement IBindingList in your collection. My solution is, as i said, to transform Entity to DataRow and back (a collection becomes a DataTable). I don''t have a sample now, but send me an e-mail at runesel@homail.com, and i''ll send you a sample tomorrow. Regards Rune >Rune, > >what exactly you mean by "adding" and "delete" doesn''t work. > >which syntax i can''t use? > >would it be possible for you to provede a simple sample, how did you do it ? > > >thanks,

Loader.
Live Chat Icon For mobile
Up arrow icon