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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

custom data binding sample code

Thread ID:

Created:

Updated:

Platform:

Replies:

7734 Oct 7,2003 09:12 PM UTC Jul 23,2007 07:59 AM UTC WinForms 7
loading
Tags: GridControl
Peter Zaborski
Asked On October 7, 2003 09:12 PM UTC

Hi, Is there any sample code on how to create a custom data binding object? ie. An object which can be used like: GridDataBoundGrid.DataSource = myCustomObject; I can't find any really good samples that describe what I need to do in order to make this possible. I think the Syncfusion docs say to implement IListSource and/or IList but no samples are available. My specific situation consists of an outer collection which contains one or more uniformly sized inner collections of floats. I'd like to bind a grid to the outer collection. And have it not only display the data correctly but also update it. And handle row and col headers as well. Any help greatly appreciated. -Peter

Administrator [Syncfusion]
Replied On October 8, 2003 09:44 AM UTC

Check out the following sample: \Essential Suite\Grid\Samples\DataBound\Hierarchical\Customers It binds the grid to an IList. Let me know if you need more information. Stefan

Peter Zaborski
Replied On October 10, 2003 02:50 PM UTC

Thanks for the pointer but I could use a more relevant sample if possible. My situation is slightly different from the customer sample. I have the following objects (simplified for this example): Data = Class which implements IList and contains a float[]. Collection = Class containing an ArrayList of Data objects. This class has a public property called DataSource which returns the ArrayList. I am using grid.DataSource = Collection.DataSource for my attempt to bind the grid to the collection. I would like the grid & collection bound so that each row dipslays the entire float[] from the corresponding Data object. Instead, each row displays each Data object's public properties. Any samples which do something close to this? I think I have an extra level of nesting in my case which the cutomer sample does not.

Administrator [Syncfusion]
Replied On October 10, 2003 03:17 PM UTC

I would have to try and work on such a sample first. But let me first explain what the grid is looking for: When you set the .DataSource for the grid it will check if the data source is IList derived and then it will check if the IList has a strongly typed indexer. If that is the case then the returned type of the strongly typed indexer is checked. So make sure the DataSource you assign to the grid has a indexer like MyData this[int index] { get; set; } The next thing is MyData should have a public default constructor that does not need any arguments. This is because the grid will try to instantiate a sample object of MyData. Once the grid has access to a instance of MyData it will then query the object for its fields. I am right now not sure if it will detect float[]. I need to take a closer look. If it does not work we will have to add support for that in the grid source code then. A workaround would be then to implement ITypedList in the collection that you assign to .DataSource Stefan

Peter Zaborski
Replied On October 10, 2003 03:20 PM UTC

That helps a lot, thanks. Any sample you can provide would be great but this gives me a great place to start. -Peter

Faulhaber
Replied On July 19, 2007 02:48 PM UTC

Hello Stefan,

it's an old thread, but it's the only matching topic i found

>So make sure the DataSource you assign to the grid has a indexer like
>
>MyData this[int index] { get; set; }
>
>The next thing is MyData should have a public default constructor that does not need any arguments.
>
>This is because the grid will try to instantiate a sample object of MyData.


I have an object like described above, but the "MyData" object contains a list of objects that represents the columns.
But the problem is that i can't initialize a sample object in the parameterless constructor because of the dynamic columns.

In the DataTable-object a new row is created by the table.NewRow() method with the defined schema of the table. The DataTable doesn't have an idexer, what does the grid there and what have i to do to implement this?

I hope you can give me a hint.

Regards
Christian

haneefm [Syncfusion]
Replied On July 20, 2007 10:59 PM UTC

Hi Christian,

Thank you for your update.

I have tested the attached sample to reproduce this issue, but could not get this. Maybe I am not following the steps that you are doing. Is it possible for you to upload us a minimal sample to reproduce the issue here? This will help us to analyse the issue further.

Sample : AddColumnCollection.zip

Best regards,
Haneef

Faulhaber
Replied On July 23, 2007 07:59 AM UTC

Hello Haneef,

i got my problem solved. I had to implement the "ITypedList"-interface that the grid creates the columns.


Thank you for your efforts.

Regards
Christian

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.

Warning Icon 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.Close Icon

;