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

Updating values in cells when grid load

Hi,

I would like to update some values in some cells when the grid is loading.
I'm using QueryCellStyleInfo event for this.
the problem is that after I change some values in the grid the event is raised again.
I would like to prevent this behavior.
Is there any other event beside QueryCellStyleInfo which raised for each cell and do it only once, or any work around for QueryCellStyleInfo event?

here is my current code:

private void gridGrpCtrlAssignEmps_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.Column != null)
{
GridGroupingControl gridGroupingControl = sender as GridGroupingControl;
Element gridElement = gridGroupingControl.Table.DisplayElements[e.TableCellIdentity.RowIndex];
Record gridRecord = gridElement.GetRecord();
//DataRowView recordDataSourceView = gridRecord.GetData() as DataRowView;

if (gridRecord != null)
{
BLActualWorkAttendance attandance = gridRecord.GetData() as BLActualWorkAttendance;
if (attandance != null)
{
if (e.TableCellIdentity.Column != null)
{

if (e.TableCellIdentity.Column.Name == this.m_Dictionary["SignIn"])
{
if (attandance.SignIn == null)
{
//if signIn is empty, call automatic insertion of sign in and actual in
//SET RECORD VALUES LIKE GridRecord.SetValue("SignIn", VALUE);
e.Handled = true;
}
}
}
}
}
}
}


3 Replies

JJ Jisha Joy Syncfusion Team January 18, 2010 09:52 AM UTC

Hi Ruslan,

The event QueryCellStyleInfo will fire continuously for any reason such as querying a cell, mousemove, mouseover. And we cannot avoid this. To monitor the cell value changed and set a column value in that record, the Table.RecordValueChanged event will be the best one.

Please let me know if you have any questions.

Regards,
Jisha


RG Ruslan Gasanbekov January 18, 2010 01:27 PM UTC

RecordValueChanged event wouldn't help me in this case.

I would like to go over the grid rows before it displayed on the first time, check some cells values and change the values in some conditions and only one time, before the grid is first loaded.

RecordValueChanged is raised only after the grid had already been loaded and displayed, and only when I change some cells values manually.


JJ Jisha Joy Syncfusion Team January 19, 2010 05:25 AM UTC

Hi Ruslan,

Here is a forum thread discussing this and it had a sample showing QueryCellInfo only being hit once.

http://www.syncfusion.com/support/forums/grid-windows/24997

You might also see the SingleQueryCellInfo technique from our sample "OTO Query Cell Info Demo" where QueryCellInfo is only hit once.

C:\Documents and Settings\[Username]\My Documents\syncfusion\essentialstudio\7.4.0.20\Windows\Grid.Windows\Samples\2.0\Performance\OTO Query Cell Info Demo\cs

Please let me know if you have any further queries.

Regards,
Jisha

Loader.
Live Chat Icon For mobile
Up arrow icon