GridViewComboBoxColumn in auto generated RadGridView for Enum DataTypes using DataTable as Data source

7 posts, 1 answers
  1. Swapnil
    Swapnil avatar
    6 posts
    Member since:
    Jan 2015

    Posted 11 Sep 2015 Link to this post

    I am binding a DataTable to RadGridView and AutoGenerateColumns="True",
    Following are the columns I have,
    dt.Columns.Add("Text", typeof(string));
    dt.Columns.Add("Number", typeof(double));
    dt.Columns.Add("CustomType", typeof(Custom));
    Custom is a Enum as follows,
    public enum Custom
        {
            One,
            Two,
            Three
        }
    Now when I bind the DataTable to RadGridView it displays Data correnctly, but when I try to change the value of custom columns I am not getting dropdown to select a value from Enum instead when I enter in edit mode it displays the Id of the selected Enum.
    I tried changing RadGridViewDataColumn to RadGridViewComboBoxColumn in AutoGeraratingColumns Event but not able to make it working.
    Please help as its pretty urgent and important.
    Attached is the screenshot for the same. 
    Thanks in Advance!!!
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 11 Sep 2015 Link to this post

    Hi,

    I prepared a sample project for you that illustrates how to handle this scenario. You can find it attached.

    Regards,
    Ivan Ivanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Swapnil
    Swapnil avatar
    6 posts
    Member since:
    Jan 2015

    Posted 16 Sep 2015 in reply to Ivan Ivanov Link to this post

    Hi Ivan,

    Thanks for the quick reply.

    The attached project has collection of model but our requirement is such that we have to use datatable. Can you please help me out by using datatable instead of Collection.

  5. Answer
    Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 17 Sep 2015 Link to this post

    Hello,

    Indeed the scenario with DataTable is a bit different, as DataRows do not contain the concrete enum value, but the underlying declaration value (e.x. int). I am attaching a slightly modified version of my initial project.

    Regards,
    Ivan Ivanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Swapnil
    Swapnil avatar
    6 posts
    Member since:
    Jan 2015

    Posted 18 Sep 2015 in reply to Ivan Ivanov Link to this post

    Perfect Thank you very much !!!
  7. Swapnil
    Swapnil avatar
    6 posts
    Member since:
    Jan 2015

    Posted 28 Sep 2015 Link to this post

    Hi Ivan,

    Everything works well with the solution you have provided but am facing issue with filtering.Can you please have a look at the attached screenshot of the solution you have provided.

    Thanks

  8. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 29 Sep 2015 Link to this post

    Hello,

    RadGridView cannot resolve the proper filtering values as the declaratin type of the DataTable column is Position, but it really contains numeric values. You can set the column's DataType to be int, which is the actual type of the bound values. Then the distinct value will be loaded as numerics. If you want to modify the way in which they are displayed, you can modify RadGridVIew FilteringControl's template.

    Regards,
    Ivan Ivanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready