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.
Unfortunately, activation email could not send to your email. Please try again.

CellValue change

Thread ID:

Created:

Updated:

Platform:

Replies:

63388 Jul 3,2007 11:34 AM Jul 5,2007 06:19 PM Windows Forms 8
loading
Tags: GridControl
Chris
Asked On July 3, 2007 11:34 AM

Hi,

we have a GGC which is bound to a business object. So what I want is to set the CellValue in one column if in another column the CurrentCellAcceptedChanges event was called (So this mechanism should be done with the underlying binding).

For example in column "A" you enter the value "10" and therefore I want to set the value of column "B" to "30". And this should be done programmatically not via databinding. So in the corresponding CurrentCellAcceptChanges event I get the GridTableCellStyleInfo of column "B" and set the style.CellValue to "30".

So do i need to call an EndEdit, NotifyChanged or what else, because the GridTableCellStyleInfo doesn't have any of these methods?

Cheers,
Chris

haneefm [Syncfusion]
Replied On July 3, 2007 01:11 PM

Hi Chris,

You can set cell value using the CurrentRecord.SetValue method in a grid. Below are the code snippets that shows this task.

void gridGroupingControl1_TableControlCurrentCellAcceptedChanges(object sender, GridTableControlCancelEventArgs e)
{
Record rec = e.TableControl.Table.CurrentRecord;
rec.BeginEdit();
rec.SetValue("ParentName", 23);
rec.EndEdit();
}

Best regards,
Haneef

Chris
Replied On July 3, 2007 02:32 PM

Hi Haneef,

thanks for your solution but the problem is, that this lines:

Record rec = e.TableControl.Table.CurrentRecord;
rec.BeginEdit();
rec.SetValue("TestB", "oo");
rec.EndEdit();

change the underlying datasource directly. I want to set the "intermediate" value of the grid and not the underlying data - the row header shows the "pen" symbol which marks that the current row is in edit mode but not comitted yet. So how can I set the value temporarily and not in the datasource?

Cheers,
Chris

Chris
Replied On July 4, 2007 04:59 AM

Just wanna know if you can give me an update on this?

haneefm [Syncfusion]
Replied On July 4, 2007 11:12 AM

Hi Chris,

One way you can do this by handling the TableControlCurrentCellAcceptedChanges event to store the current record intermediate values in a hashtable. You can display the current record intermediate values by using the hashtable in a TableControlDrawCellDisplayText event. Belwo are the code snippet

Hashtable CurrentRecordBuffer = new Hashtable();

void gridGroupingControl1_TableControlCurrentCellAcceptedChanges(object sender, GridTableControlCancelEventArgs e)
{
if (!CurrentRecordBuffer.Contains("Description"))
CurrentRecordBuffer.Add("Description", 23);
else
CurrentRecordBuffer["Description"] = 23;
}

void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
if (e.TableControl.CurrentCell.RowIndex == e.Inner.RowIndex)
{
GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
if (style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record
&& style.TableCellIdentity.Column != null )
{
string sCellValue = Convert.ToString( CurrentRecordBuffer[style.TableCellIdentity.Column.Name] );
if( sCellValue != "" )
e.Inner.DisplayText = sCellValue;
}
}
}

Please refer to the attached sample for implementation and let me know if this helps.
GGC_RecordIntermediateValue.zip

Best regards,
Haneef

Chris
Replied On July 4, 2007 12:49 PM

Hi Haneef,

thank you for your update but the problem with this suggestion is, that we are using a custom cell renderer in our real world example. The custom renderer decides if it should show a combobox or only a plain text box. The decision is based on the cell value in the OnInitialize function of the renderer.

So we need to set the cell value in the CurrentCellAcceptChanges. Furthermore if you change the value (of the cell which was changed during the CurrentCellAcceptChanges) and then click the arrow down key to confirm the row - The cell displays the old value again.

Any help would be great
Chris

haneefm [Syncfusion]
Replied On July 4, 2007 04:37 PM

Hi Chris,

Bydefault, Grid does call the EndEdit method for commiting the changes in a grid to underlying datasource.If you want to set the cell value in a TableControlAcceptChanges event without saving the underlying datasource then you can avoid calling the EndEdit method. Below is a code snippet to show this task.

Sample : MGGC_RecordIntermediateValues.zip

Best regards,
Haneef

Chris
Replied On July 5, 2007 01:22 PM

Hi Haneef,

thanks for your suggestion, but in our example it doesn't work. I have attached a sample. Enter "test" in the first cell (first row) then press the arrow key right -> you will see the change. After that press the arrow key down to submit the row. When you then press the arrow key up, you will see the old value.

Any ideas,

Best regards,
Chris

MGGC_RecordIntermediateValues.zip

haneefm [Syncfusion]
Replied On July 5, 2007 06:19 PM

Hi Chris,

Thank you for bringing this issue in our attention.

I am able to see this issue that you have mentioned here. But this can be solved by using the below codes in the CurrentRecordContextChange.

//CurrentRecordContextChange event.
if (e.Action == CurrentRecordAction.EndEditCalled
&& e.Record.IsRecord())
{
Table table = e.Record.ParentTable;
Record record = e.Record.GetRecord();
object[] oldValues = new object[e.Record.ParentTableDescriptor.Fields.Count];
object[] newValues = new object[e.Record.ParentTableDescriptor.Fields.Count];
int index;
foreach (FieldDescriptor field in e.Record.ParentTableDescriptor.Fields)
{
index = e.Record.ParentTableDescriptor.Fields.IndexOf(field);
oldValues[index] = record.GetOldValue(index);
newValues[index] = record.GetValue(field);
}
table.CurrentRecordManager.ResetCurrentRecord(record);

for (int i = 0; i < oldValues.Length; i++)
if (oldValues[i] != newValues[i])
table.UnsortedRecords[record.GetSourceIndex()].SetValue(e.Record.ParentTableDescriptor.Fields[i], newValues[i]);
}

Please refer the modified sample in the below link which illustrates the above.
ModifiedGGC_DataBinding.zip

Best regards,
Haneef

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;