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

Split Columns

HI,
We are using Syncfusion Essential Studio 4.4.0.55 (Grid Data Bound Grid).

We have a requirement to display part of the data in the grid as split coulmns. I have attached a sample sheet showing the exact requirement of how the data has to be displayed in the grid.

To bind the data we are using custom entities rather then data sets.

Please let me know how it can be achived sample code would help.

Thanks
Hazrat

Sample109.zip

16 Replies

AD Administrator Syncfusion Team February 19, 2007 07:52 PM UTC

Hi Tannearu,

One way to do this would be to derive a custom cell type like the ones( \4.4.0.49\windows\Grid.Windows\Samples\CustomCellTypes\SliderCells). It requires a model class and a renderer class. The model class handles the serialization requirements for the control and creates the renderer class. The renderer class handles the UI requirements of the cell. Then to use your custom cell type in a grid, you need to register this celltype with the grid as shown in this sample.s\Syncfusion\Essential Studio\4.4.0.49\windows\Grid.Windows\Samples\CustomCellTypes.

Here is a minimal sample that show you "How to add the multiple textbox celltype in a cell"
TwoTextBoxCell.zip

Best regards,
Haneef


TH Tannearu Hazarathaiah Gupta February 20, 2007 11:36 AM UTC

Hi Haneef,
Thanks for your reply.

We are using Syncfusion Essential Studio 4.4.0.55 (Grid Data Bound Grid).

I am unable to find Syncfusion\Essential Studio\4.4.0.49\windows\Grid.Windows\Samples\CustomCellTypes
SliderCells



Reagards
Tannearu

>Hi Tannearu,

One way to do this would be to derive a custom cell type like the ones( \4.4.0.49\windows\Grid.Windows\Samples\CustomCellTypes\SliderCells). It requires a model class and a renderer class. The model class handles the serialization requirements for the control and creates the renderer class. The renderer class handles the UI requirements of the cell. Then to use your custom cell type in a grid, you need to register this celltype with the grid as shown in this sample.s\Syncfusion\Essential Studio\4.4.0.49\windows\Grid.Windows\Samples\CustomCellTypes.

Here is a minimal sample that show you "How to add the multiple textbox celltype in a cell"
TwoTextBoxCell.zip

Best regards,
Haneef


AD Administrator Syncfusion Team February 20, 2007 03:58 PM UTC

Hi Tannearu,

Please use the below path.
[you installation path]\Syncfusion\Essential Studio\4.4.0.55\windows\Grid.Windows\Samples\CustomCellTypes\SliderCells

or

The Browser Sample can be accessed from Start Menu >> Programs >> Syncfusion >> Essential Suite 4.4.0.55 >> Windows Forms >> Browser Sample. And then you can get the SilderCells sample from Grid.Grouping >>>CustomCellTypes node

Best regards,
Haneef


AP Aditi Pisal February 22, 2007 07:29 AM UTC

Hi Haneef,

This is in context to your previous reply for using the CustomCell exe.
I have syncfusion 4.4.0.55 but when I click on "Browse Samples" I get error of "SampleBroweser.exe" not found.
Pls suggest an alternative for the above.
Kindly consider we are using "GridGroupingControl" and require to split the data into 2 rows for a particular column.
Pls reply as soon as possible.



Sample1091.zip


AD Administrator Syncfusion Team February 22, 2007 08:46 PM UTC

Hi Aditi,

The attached sample shows you "How to split the data into two rows for a cell in a GroupingGrid?". It also implements the GridGenericControlCellModel and GridGenericControlCellRenderer for creating a custom cell type ina grid. Please refer to the attached sample and let me know if this helps.

Sample : SplitDataCell.zip

Best regards,
Haneef


AP Aditi Pisal February 23, 2007 06:47 AM UTC

Hi Haneef,
Thanks for the sample.
Can you pls suggest how to bind this custom control with the Entity collection instead of a dataset and hard coded values.
Also how to capture the changed text from these custom control textboxes.

Can we use the QueryValue() event and the SaveValue() event in this case.
Pls reply with sample example.





TG Tod Golding May 29, 2007 05:14 PM UTC

I am evaluating your control and this sample (SplitDataCell.zip) is at the heart of what I'm struggling with. When I found it, I thought I'd be all set. However, the sample code you have provided demonstrates the same issue I'm facing (actually two issues I'm facing)

1) When you edit enter data into your custom cell, the values are not retained when you leave the cell (in fact, the data you initialize the cells with is also not shown)

2) I want to bind my custom cell type to my own entity object (without implementing IConvertible). Is that possible with this approach? Should I just put my data in the extended style properties and set/get it that way?

I really love your control, but this one area has me concerned (since custom cell types are big part of my solution). Any chance you can tweak this example to make it work (and have it support "add new")?

>Hi Aditi,

The attached sample shows you "How to split the data into two rows for a cell in a GroupingGrid?". It also implements the GridGenericControlCellModel and GridGenericControlCellRenderer for creating a custom cell type ina grid. Please refer to the attached sample and let me know if this helps.

Sample : SplitDataCell.zip

Best regards,
Haneef


HA haneefm Syncfusion Team May 29, 2007 09:39 PM UTC

Hi Tod,

Here is a minimal sample that shows you "How to bind custom celltypes in a GroupingGrid?". It also uses the IBindinglist as datasource. Please try the sample and let me know if this helps.

Sample :ModifiedSplitDataCell.zip

Best regards,
Haneef


TG Tod Golding May 30, 2007 07:21 PM UTC

Thanks for you help. I've made more progress but I still can't get passed the one fundamental problem that landed me here. The list of objects I'm binding two has properties that are my own custom objects. When I edit the cell value for the cells that are bound to these custom types, the grid tells me I must implement ICovertible for the type that's bound to that cell.

I noticed your example has a Customer object and doesn't complain when leaving the cell so I'm not sure why yours would work and mine would. My data source is my own IList collection and the objects in my collection have custom objects as properties. I am not implement IBindingList or many of the interfaces you are in your DataCollection, but I assume those aren't required.

So, the question is: how do I preven the cell from requiring "IConvertible"? If I'm binding to a datasource of IMyList and "MyObject" has a "MyCustomObjectProperty" I want to be able to bind a column to "MyCustomObjectProperty" without implementing any other special interfaces. Is that possible? If not, is there some other way to get my cell to stop generting the "IConvertible" error message?

I'm so close, but I can't get over the last hurdle. Your help is greatly appreciated.


>Hi Tod,

Here is a minimal sample that shows you "How to bind custom celltypes in a GroupingGrid?". It also uses the IBindinglist as datasource. Please try the sample and let me know if this helps.

Sample :ModifiedSplitDataCell.zip

Best regards,
Haneef


HA haneefm Syncfusion Team May 30, 2007 11:28 PM UTC

Hi Tod,

Issue 1: Storing the values.
You need to override the OnSaveChanges method in your custom cell renderer and save the value your selfy. Please refer these and let me know if this helps.

http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=54409
CustomBindObject Documentation

Issue 2: Catches the exception.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
If you wan to cancel the exception and you need to handle the Table.ExceptionRaised event and set e.Cancel to true. Here is a code snippet

ggc.Table.ExceptionRaised += new Syncfusion.Grouping.ExceptionRaisedEventHandler(Table_ExceptionRaised);
void Table_ExceptionRaised(object sender, Syncfusion.Grouping.ExceptionRaisedEventArgs e)
{
e.Cancel = true;
}

Also refer to the below forum thread that shows you "How to customize the error-icon in a cell?".
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=55049

Best regards,
Haneef


TG Tod Golding May 31, 2007 03:22 AM UTC

I'm sorry to be such a pest. I realize I posted about 15 varieties of the same question. I had hoped the context of the prior threads would help clarify the problem. I'll consolidate here since I still don't think we're in sync.

Question #1
===========
From you response, I'm assuming that I do *not* have to implement IConvertible to get this to work, right?

Question #2
============
I have implemented OnSave() as you describe here following your example. I still get the error that requires implementation of IConvertible. Setting my custom type into the CellValue doesn't seem to resolve the issue. Is is supposed to?

Question #3
===========
I believe that binding to interfaces (instead of objects) is at the root of my IConvertible issue. I bound one of your out-of-the-box cells (a combo box cell with my custom objects) to a column of a custom type. At first, I was using an interface for my type (IMyCustomObject). That returned an IConvertible error. I changed that same bound column to use the concrete object (MyCustomObject) *instead of the interface* and the binding error went away. This would suggest that interfaces cannot be used for binding. I wondered, in fact, if your binding implemenation counted on ToString() and the other core "object" methods that would not be available when binding to an interface. So, this make me wonder (given question #2 above) if my binding problem for my custom cell type (which is using an interface) is also being impacted by the same problem. Can you verify that binding to a custom property *that is an interface* works?

Question #4
===========
Do I really need separate "draw" and "edit" cells to hold the representation of my custom cell type? I could see that being useful if they were rendered differently, but they're not. However, all of your examples use separate "draw" and "edit" data members. Can you explain why these are needed?




>Hi Tod,

Issue 1: Storing the values.
You need to override the OnSaveChanges method in your custom cell renderer and save the value your selfy. Please refer these and let me know if this helps.

http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=54409
CustomBindObject Documentation

Issue 2: Catches the exception.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>
If you wan to cancel the exception and you need to handle the Table.ExceptionRaised event and set e.Cancel to true. Here is a code snippet

ggc.Table.ExceptionRaised += new Syncfusion.Grouping.ExceptionRaisedEventHandler(Table_ExceptionRaised);
void Table_ExceptionRaised(object sender, Syncfusion.Grouping.ExceptionRaisedEventArgs e)
{
e.Cancel = true;
}

Also refer to the below forum thread that shows you "How to customize the error-icon in a cell?".
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=55049

Best regards,
Haneef


HA haneefm Syncfusion Team May 31, 2007 11:57 PM UTC

Hi Tod,

Thank you for your crystallize explanation.

Question #1
===========
From you response, I'm assuming that I do *not* have to implement IConvertible to get this to work, right?
>>>>>>>>>>>>>>>>>
Yes, You no need to implement the IConvertible interface to work-around this problem. But you need to override the OnSaveChanges method. The attached sample implements the Activator class in the OnSaveChanges override method .Please refer the attached sample and let me know if this helps.

Question #2 and Question #3:
============
I have implemented OnSave() as you describe here following your example. I still get the error that requires implementation of IConvertible. Setting my custom type into the CellValue doesn't seem to resolve the issue. Is is supposed to?
>>>>>>>>>>>>>>>>>
You can use the Activator.CreateInstance method to create new instance of the required base class in OnSaveChanges method. Here is a code snippet that show this task.

protected override bool OnSaveChanges()
{
Type type = this.Grid.Model[this.RowIndex,this.ColIndex].CellValue.GetType();
Type ctype = this.ControlValue.GetType();
if (type == ctype)
return base.OnSaveChanges();
else
{
object objBaseForClass = Activator.CreateInstance(type);
foreach (PropertyInfo propBaseInfo in type.GetProperties())
{
foreach (PropertyInfo propChildInfo in ctype.GetProperties())
{
if (propBaseInfo.Name == propChildInfo.Name)
{
object objPropertyValue = propChildInfo.GetValue(this.ControlValue, null);
if (propBaseInfo.GetSetMethod() != null)
{
propBaseInfo.SetValue(objBaseForClass, objPropertyValue, null);
break;
}
}
}
}
this.Grid.Model[this.RowIndex, this.ColIndex].CellValue = objBaseForClass;
}
return true;
}

Question 4:
============
Do I really need separate "draw" and "edit" cells to hold the representation of my custom cell type? I could see that being useful if they were rendered differently, but they're not. However, all of your examples use separate "draw" and "edit" data members. Can you explain why these are needed?
>>>>>>>>>>>>>
Yes, you will need to have two controls(edit and draw). one for drawing the cell when it is inactive and shared among cells. The other when it is in edit mode.The attached sample have two controls and in the OnDraw method they distinguish between active and inactivate state of the cell.

Please refer to the attached sample for implementation.
http://websamples.syncfusion.com/samples/Grid.Windows/F56622/main.htm

Best regards,
Haneef


TG Tod Golding June 6, 2007 09:09 PM UTC

I'm still struggling with data binding issues and my custom cell type. Your example helped, but it didn't really address the problem I was describing. I'm trying to bind my custom cell type to an object that has a *list* as one its properties. So, my binding object is:

public class MyBindableObject
{
...
...
public IList CustomObjectList
{
...
}
}

And, in the code, I bind a collection of MyBindableObject to my GGC:

...
List myDS = new Listgrid.DataSource = myDs
...

Binding my custom cell type to the CustomObjectList above generates the "Must impement IConvertible" error (event when I override allthe methods you suggest).

I'm uploading a revised version of your sample that demonstrates the problem. I changed your "Data" class to have a customer property to an IList. Now, when you try to leave the cell you get the "Must implement IConvertible" error.

I'm nearing the end of my 30-day evaluation window and I'm still worried that I'm not going to get these issues resolved prior to the end of my evaluation period. Maybe you'll come up with something that gets me passed this. You help would be greatly apprecited.

The example is attached.




>Hi Tod,

Thank you for your crystallize explanation.

Question #1
===========
From you response, I'm assuming that I do *not* have to implement IConvertible to get this to work, right?
>>>>>>>>>>>>>>>>>
Yes, You no need to implement the IConvertible interface to work-around this problem. But you need to override the OnSaveChanges method. The attached sample implements the Activator class in the OnSaveChanges override method .Please refer the attached sample and let me know if this helps.

Question #2 and Question #3:
============
I have implemented OnSave() as you describe here following your example. I still get the error that requires implementation of IConvertible. Setting my custom type into the CellValue doesn't seem to resolve the issue. Is is supposed to?
>>>>>>>>>>>>>>>>>
You can use the Activator.CreateInstance method to create new instance of the required base class in OnSaveChanges method. Here is a code snippet that show this task.

protected override bool OnSaveChanges()
{
Type type = this.Grid.Model[this.RowIndex,this.ColIndex].CellValue.GetType();
Type ctype = this.ControlValue.GetType();
if (type == ctype)
return base.OnSaveChanges();
else
{
object objBaseForClass = Activator.CreateInstance(type);
foreach (PropertyInfo propBaseInfo in type.GetProperties())
{
foreach (PropertyInfo propChildInfo in ctype.GetProperties())
{
if (propBaseInfo.Name == propChildInfo.Name)
{
object objPropertyValue = propChildInfo.GetValue(this.ControlValue, null);
if (propBaseInfo.GetSetMethod() != null)
{
propBaseInfo.SetValue(objBaseForClass, objPropertyValue, null);
break;
}
}
}
}
this.Grid.Model[this.RowIndex, this.ColIndex].CellValue = objBaseForClass;
}
return true;
}

Question 4:
============
Do I really need separate "draw" and "edit" cells to hold the representation of my custom cell type? I could see that being useful if they were rendered differently, but they're not. However, all of your examples use separate "draw" and "edit" data members. Can you explain why these are needed?
>>>>>>>>>>>>>
Yes, you will need to have two controls(edit and draw). one for drawing the cell when it is inactive and shared among cells. The other when it is in edit mode.The attached sample have two controls and in the OnDraw method they distinguish between active and inactivate state of the cell.

Please refer to the attached sample for implementation.
http://websamples.syncfusion.com/samples/Grid.Windows/F56622/main.htm

Best regards,
Haneef

TodTwoCell.zip


HA haneefm Syncfusion Team June 6, 2007 11:17 PM UTC

Hi Tod,

I couldn't see MyBindableObject class in your sample. So, I have modified your attached sample to bind IList to the custom celltype. I have tested the modified sample to reproduce this problem, but i could not get the problem. I recommend modifying the attached sample or any of our browser sample to reproduce the problem. This helps us to realize a better solution at the earliest.

Sample :TodTwoCell.zip

Best regards,
Haneef


TG Tod Golding June 7, 2007 06:21 AM UTC

First, I think we're experiencing some communication difficulties. Here's where we stand:

Point 1: The example I gave in my prior message referencing MyBindableObject was just an example of the scenario. It was not referencing any code or classes from the example. If you look at the original example I provided, I had already changed the "Data" class from your example to make the Customer property an IList.

Point 2: The original example I provided *and* this modified example that you returned both demonstrate the issue I'm disccusing. While the custom cell appears to work when you first bring up the grid, it fails when you enter data for the cell and navigate away. Here's the steps to reproduce the problem:

1) Run the latest example you created

2) Enter data for the custom cell

3) Click in the cell to the right of the custom cell.

4) The system shows the "Must support IConvertible" error.

NOTE: It's easier to see this if you turn off the red background for the custom cell.



>Hi Tod,

I couldn't see MyBindableObject class in your sample. So, I have modified your attached sample to bind IList to the custom celltype. I have tested the modified sample to reproduce this problem, but i could not get the problem. I recommend modifying the attached sample or any of our browser sample to reproduce the problem. This helps us to realize a better solution at the earliest.

Sample :TodTwoCell.zip

Best regards,
Haneef


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

Hi Tod,

Please follow the below forum thread for more details.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=62162

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon