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

Which Control to Use?

Hi, I have a very generic question this time. Let’s say we have a datatable which hold our data and all of the data is not being displayed in the grid. Depending upon the condition we display some of the data. This grid is editable so user can change the value and we have to save it back to database somehow. We might need to refresh the grid frequently based on condition to remove some of the data and add some of the data from the datatable but we have to keep our new values which user already has changed. What would be the best way to proceed? Which grid should I use? I mean GridControl, GridDataBoundGrd or VirtualGrid. If case of VirtualGrid, would it be possible to use formula on some of the cell? Please do answer for this question. I would really appreciate your help. Thanks

8 Replies

AD Administrator Syncfusion Team May 26, 2004 10:01 PM UTC

If it is data in a DataTable, then I would probably try to use a GridDataBoundGrid. If you want to use formulas in a GridDataBoundGrid or in a virtual GridControl, you do have to manage storage to maintain the style.FormulaTags for each of the formula cells.


VI Vivek May 27, 2004 10:22 AM UTC

Yes, I do agree that my data is in a datatable but the thing is that I might not display all the rows and column always. I might display only few columns and few rows at a time. I might be wrong but as per my understanding we bound out datatable to GDBG, it display all the rows in a column or all the rows and columns in a grid. I might just want to display rows 1,3,5,7.. From the datatable. Please correct me I advice accordingly. Thanks


AD Administrator Syncfusion Team May 27, 2004 10:27 AM UTC

Would you be able to use a DataView as a filter, and bind to the DataView? That way only rows matching your criteria should be displayed. >Yes, I do agree that my data is in a datatable but the thing is that I might not display all the rows and column always. I might display only few columns and few rows at a time. > >I might be wrong but as per my understanding we bound out datatable to GDBG, it display all the rows in a column or all the rows and columns in a grid. I might just want to display rows 1,3,5,7.. From the datatable. > >Please correct me I advice accordingly. > >Thanks >


AD Administrator Syncfusion Team May 27, 2004 10:36 AM UTC

You control the columns that appear in a GridDataBoundGrid through the grid.GridBoundColumns collection. If your DataTable has 50 column columns in it, but you only create and add 4 GridBoundColumns to the this.grid.GridBoundColumns collection, then you will only see these 4 columns in the grid. By default, the grid creates and adds GridBoundColumns for every column in the DataTable to the this.grid.Binder.InternalColumns collection (which is used when you do not explicitly add GridBoundColumns to the this.grid.GridBoundColumns collection). As far as restricting the rows, then one way to do it is as Marina suggested using dataTable1.DefaultView.RowFilter to pick out the rows you want. Another option is to design the original query (SQl or ???) such that the original DataTable only holds the rows of interest to you. Another option is to use dataTable.Rows.Remove to delete rows you are not interested in.


VI Vivek May 27, 2004 11:24 AM UTC

So the bottom line is that, try to use GDBG instead of using GridControl and avoid setting values on an individual cell level. This is my understanding that if I were to use GridControl then I have to read values from datatable and set it to each cell. Or please advise if there is some other way to display data in GridControl? If we are setting value in each cell using datatable, would that be called a virtual grid? Or virtual grid is totally different. Please do reply. Thanks


AD Administrator Syncfusion Team May 27, 2004 12:12 PM UTC

>This is my understanding that if I were to use GridControl then I have to read values from datatable and set it to each cell. If you use the GridControl virtually, you do not have to ''set'' the values into each cell. Instead, you handle the QueryCellInfo event. When the grid wants a value for a particular cell for any reason, it fires this event, passing in e.ColIndex and e.RowIndex to identify the cell being requested. At that point, your handler will conditionally set e.Style.Text (or e.Style.CellValue) along with any other e.Style properties you want to set. In this manner, you are providing the data on demand to the grid. When the grid wants a value, it will demand it through QueryCellInfo. And you would have to provide it at that point. And you can provide it from any data source, including a DataTable. There are several virtual grid samples that we ship (look in the Getting Start section of the samples) as well as a discussion of virtual grid in the User''s Guide.


VI Vivek May 27, 2004 12:31 PM UTC

So basically I should try use GDBG f I can use instead of using GridControl. So when should I really use GridControl or VirtualGrid? I little confuse here because VirtualGrid is kind of GridControl in which we set the data at each cell from some other source that could be very well a datatable. So if I keep my data in a datatable and use GridControl and set my data in each cell as per my requirement, would it be called VirtualGrid? I understand that I have to implement some function in VirtualGrid. I can really see and understand the use of GDBG but I am still trying to find How & When Should I use GridControl when I have some data to display that coming from database? & How & When Should I use VirtualGrid when I have some data to display that coming from database? What is the Difference between GridControl and VirtualGrid? Please do help me. Thanks


AD Administrator Syncfusion Team May 27, 2004 12:57 PM UTC

>>So if I keep my data in a datatable and use GridControl and set my data in each cell as per my requirement, would it be called VirtualGrid? No. If you put your data into a GridControl, you are not using it virtually. A GridControl can be used in two different ways. 1) You can explicitly set your data into the grid''s internal data object. 2) You can choose to NOT set your data into the grid''s internal data object, but instead provide the data to the grid on demand in the QueryCellInfo. This is virtual mode. It is the same GridControl in both cases. The difference is strictly in how it is being used. What''s the difference? If you have 10 million cells in a DataTable, then if you use 1, you have to copy 10 million cells to the grid. If you use 2, you do not have to do this since the grid does not hold any data. In this case, when the grid wants data, if will ask you for it cell by cell through QueryCellInfo. The main reason for using a virtual grid is if you need complete, real time control of any aspect of teh display of your data. A virtual grid is completely dynamic since the data is always provide just as the grid needs it. Other reasons to use virtual grid include your data source is huge and you do not want the overhaed of an initial load time. Generally, using a GridDataBoundGrid or a GridControl that holds the data is simpler as having access to teh data lets teh grid do things for you (like moving columns or sorting). In a virtual grid, you have to add extra code to manage these things. But if you need the absolute fastest grid possible with the most flexible control, then a virtual GridControl may be the best choice. Have you read the sections in our user''s guide that describe virtual mode?

Loader.
Live Chat Icon For mobile
Up arrow icon