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

Getvalue of the columns in GridGroupingControl

Hi, I am looping through records in the gridgroupingcontrol. I am using gridgroupingControl.Table.Records.Count to loopthrough. How to get the value of the columns.. in a row? Thanks in advance, Prathima

9 Replies

AD Administrator Syncfusion Team June 16, 2005 08:12 AM UTC

Given a Record rec, you use the rec.GetValue method to get a value of a particular column.

PV Prathima Venkobachar June 16, 2005 08:18 AM UTC

How to get record..? Basically i want to do validations on the cloumns values. I will not be knowing the column index .It is dynamiclly bound based on the user preference. I want to search for the particular column and value and apply validation. So i am looping through all the rows and trying to find out the values. Is there any better way of doing this..?

AD Administrator Syncfusion Team June 16, 2005 08:40 AM UTC

You said you were looping through the records using gridgroupingControl.Table.Records.Count, correct? So, you can index the gridgroupingControl.Table.Records collection to get the record you are currently on in your loop. The Record.GetValue can access the value by passing a string name if you know the name of the column you are searching for. Do you need to do this validation all at once when you user is leaving the grid, or can you do it as the user leaves the particular cell. If you need to do it all at once, then what you are trying to do is probably as good as any (except it may be more efficient to directly use your data source and loop through it doing your checks, and not have to go through the extra level of the grid to get at the same data). If you can do the validation cell by cell, then you can use teh grid.TableControlCUrrentCellValidating event. Here is a forum thread that has code snippets showing how you can use this event. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=22307

PV Prathima Venkobachar June 16, 2005 08:52 AM UTC

Yeah good idea..I can use my datatable instead of using the grid to get the same value. I am doing validation finally when the user leaves the grid and clicks on the button to save the record. Thanks for the reply. Prathima

PV Prathima Venkobachar June 16, 2005 10:50 AM UTC

Hi, How to set the focus for the column which has wrong data...? I will knowing which and which column. Thx, Prathima

AD Administrator Syncfusion Team June 16, 2005 10:56 AM UTC

If you know the GridRecord rec, then you can use; rec.SetCurrent("ColumnName");

PV Prathima Venkobachar June 16, 2005 11:08 AM UTC

It work fine. Thx for ur great help. Prathima

PV Prathima Venkobachar June 17, 2005 06:55 AM UTC

Sorry for re-opening. This works fine on click of the button. But same validation i am calling on following event. this.gridgroupingControl.SyncfusionGridControl.SourceListListChanged +=new TableListChangedEventHandler(ggdView_ListChangedEventHandler); On this event if the I am checking, if(e.ListChangedType == ListChangedType.ItemChanged){} if the it is true,then I will call my update.before calling save/update i do the validation. But the cursor doesn''t set back to the wrong column. How can I handle this..? Thanks, Prathima

AD Administrator Syncfusion Team June 17, 2005 09:15 AM UTC

In the SourceListListChanged event, the record has already been saved, and you are too late in the moving to a new position process to interupt the move. Instead, you can try using TableControlCurrentCellMoving. You can test if you are changing a row, and if you are, you can perform you additional checks and cancel the move and move to the bad cell if necessary. Here is a little sample that will not let you leave a row if Col1 is negative. http://www.syncfusion.com/Support/user/uploads/GGC_EmptyDataSource_2cbe0f9c.zip

Live Chat Icon For mobile
Up arrow icon