bind to IEnumerable<IDictionary<string, object>>

3 posts, 0 answers
  1. Maxim
    Maxim avatar
    63 posts
    Member since:
    Mar 2007

    Posted 15 May 2012 Link to this post

    Hi,
    Is there a way to bind to IEnumerable<IDictionary<stringobject>>.

    Thanks
  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 17 May 2012 Link to this post

    Hello Maxim,

    Thank you for writing.

    This is not a supported functionality in RadGridView. You can bind to IEnumerable<T>, where T object must contain public properties to bind properly to RadGridView control. More information about binding you can find in our online documentation.

    I hope this helps. 

    Kind regards,
    Julian Benkov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. Holger Boskugel
    Holger Boskugel avatar
    27 posts
    Member since:
    Apr 2012

    Posted 23 May 2012 Link to this post

    Hello Maxim,

    how Julian stated, wrap your IEnumerable<IDictionary<string, object>> with a Wrapper.
     
    As I suppose, your IEnumerable are the rows and the pairs in your IDictionary are the "named" or mapped values for the Cells, where the Key is the Name, UniqueName or FieldName of the Column? In this case you have two ways:

    a) Wrapper which creates a List with dynamic created objects (Key = Property) or
    b) Wrapper of DataTable which easily? copies the pairs to the DataTable
    c) Wrapper of IDataReader which get consumed by the Load method of a DataSet

    where I mean the solution c) is simple to implement if you provide the related metadata for the "Fields" (your pair Keys). So you read directly from IEnumerable instance. Drawback is the lot of implementation of Methods from the interface. Read() will be connected to MoveNext() of IEnumerator<IDictionary<string, object>>, Values read from Current of the Enumerator and the access with FieldIndex of IDataReader goes via a metadata list of columnnames or columnmetadata collection (can be a List<DataColumn> or better KeyedCollection<DataColumn>). So also GetName and GetOrdinal of the interface can be supported.

    As alternate to List<DataColumn> you can hold a none filled DataTable, where you only add the Columns for holding columns metadata.

    Hope that helps!


    Regards from Leipzig

    Holger
Back to Top