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

Custom cell renderer and custom object

Hi,

we have a GGC which is bound to a custom object via binding. This custom object (BindingList) contains several "row" objects. A row object itself contains native properties (like string, int, double ...) but also custom properties. To handle these custom properties we have implemented custom cell types. I have attached a sample to explain my problem.

When you start the sample you can see a grid with three columns (First Name, Last Name, Data Object). Where the "Data Object" column is a custom property whith a custom cell type. The grid contains one row. Now make a mouse click in the cell of the first row and last column ("Data Object" column). Now when you press the arrow down key on the keyboard the focus is in the Add-New row. A new row object is automatically created and the "Data Object" column contains the value "0". Now when you press a number key to enter a new value, nothing happens. It seems the custom cell renderer doesn't get the focus.

When you press the left arrow key and then the right arrow key, you can enter a value. But with a click on the return key, the cell value isn't saved. It's difficult to describe, but the attached sample shows the behavior.

Do you know what's the problem with the custom cell renderer here? and why is the cell value not saved?

Thanks,
Markus

5 Replies

FG Franz Gsell June 11, 2007 12:53 PM UTC

Sorry I forgot the attachement

CustomObjectGrid.zip


HA haneefm Syncfusion Team June 11, 2007 10:31 PM UTC

Hi Markus,

Here is a modified sample that shows you "How to bind custom celltypes in a GroupingGrid?". It also uses the renderer.OnSaveChanges() method to add a new record to grid. Please try the sample and let me know if this helps.

Sample : ModifiedCustomObjectGrid.zip

Best regards,
Haneef


FG Franz Gsell June 12, 2007 06:54 AM UTC

Hi Haneef,

thank you for your modifications. So I have seen that you have removed the OnQueryCellStyleInfo and OnTableControlCurrentCellMoved method. You are currently handling the whole stuff in the OnSaveChanges method and this works fine.

The problem is that I need the OnQueryCellStyleInfo method, because in our real world example we have different cell types for the "Data Object" column, because there are different types in that column. The different types depend on another column. With the OnQueryCellStyleInfo we can set the cell type dynamically.

So your idea with the part:

else
{
typedValue = new CustomObject();
typedValue.DoubleValue = Double.Parse(TextBox.Text);
GridTableControl tc = this.Grid as GridTableControl;
GridTableCellStyleInfo info = this.Grid.Model[RowIndex, ColIndex] as GridTableCellStyleInfo;
if (tc != null && info.TableCellIdentity.DisplayElement.Kind == Syncfusion.Grouping.DisplayElementKind.AddNewRecord)
{
tc.Table.AddNew();
}
this.Grid.Model[RowIndex, ColIndex].CellValue = typedValue;
CurrentCell.IsModified = false;
return true;
}

in the OnSaveChanges method doesn't work for us - because we don't know if we have a custom object or something else. Because the same cell type can be used for another type in the same column.

Can the problem be solved with our approach (OnQueryCellStyleInfo and OnTableControlCurrentCellMoved)?

Cheers,
Markus


FG Franz Gsell June 13, 2007 05:47 PM UTC

Hi,

I just wanna bring this thread up - any news about that issue?

Cheers
Markus


HA haneefm Syncfusion Team June 13, 2007 11:57 PM UTC

Hi Markus,

You can try these code in a OnSaveChanges method and let me know if this helps.

protected override bool OnSaveChanges()
{
GridTableControl tc = this.Grid as GridTableControl;
GridTableCellStyleInfo info = this.Grid.Model[RowIndex, ColIndex] as GridTableCellStyleInfo;
ICustomObject typedValue = this.Grid.Model[RowIndex, ColIndex].CellValue as ICustomObject;
if (typedValue != null)
{
if (tc != null && info.TableCellIdentity.DisplayElement.Kind == Syncfusion.Grouping.DisplayElementKind.AddNewRecord)
tc.Table.AddNew();

ICustomObject objBaseForClass = Activator.CreateInstance(typedValue.GetType()) as ICustomObject;
objBaseForClass.DoubleValue = Convert.ToDouble(this.ControlText);
ControlValue = typedValue;
this.Grid.Model[RowIndex, ColIndex].CellValue = objBaseForClass;
CurrentCell.IsModified = false;
return true;
}
else
return false;
}

Please refer to attached sample for implementation.
CustomObjectGrid.zip

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon