Home Forums WPF controls Xceed DataGrid for WPF Cant edit values on new rows..

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24927 |

    Hi there,

    i know this is a stupid question, but i simply cant figure out the problem
    if i create a new row for a DataTable bound to a DataGridControl using a DataView (DataView.AddNew()), i cant edit any cell in the newly created row.. why?
    If i initialize a column (i.e. NewRow[Column1] = “”), then i can edit that one column/cell

    Thanks for any help, best regards
    b.greber

    Imported from legacy forums. Posted by Benno (had 563 views)

    Xceed Support
    Member
    Post count: 5658

    What is most likely happenning is that the cell value is null and therefore the grid has no idea what editor display, hence none is displayed.

    To verify this assumption, I would need to see the code that you are using to bind the grid.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 242 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi jenny,

    I bind my grid simply using the DataContext:

    C#: this.DataContext = myDataTable.DefaultView;
    XAML: <xcdg:DataGridControl ItemsSource=”{Binding}”/>

    To your assumption, I didnt think that way, that could be the problem 🙂
    To prevent this, do I have to assign a CellEditor to each column in the grid?
    Another way could be to set a default value on each column in the DataTable.. (i.e. 0 or “”) ?

    Thanks for your help, best regards
    b.greber

    Imported from legacy forums. Posted by Benno (had 439 views)

    User (Old forums)
    Member
    Post count: 23064

    I just found out that setting AutoCreateColumns=”True” solves my problem.
    But why that? The column-definitions of my DataGridControl include exact all the columns of the DataTable it is bound to.
    With AutoCreateColumns set to “True” I can edit all the values in my grid, if set to “False” (this doesnt change anything on my columns since they are exactly mapped in the <DataGridControl.Columns> section), I cant edit cells which are DBNull

    Could someone please explain me why? 🙂

    Imported from legacy forums. Posted by Benno (had 490 views)

    Xceed Support
    Member
    Post count: 5658

    When AutoCreateColumns is set to true, we automatically detect the properties or DataColumns based on the data source.

    In most cases, we can resolve the data type as well. When we can detect the data type for the column, we automatically assign one of the default editors to the column, if possible ( basic data types ).

    When AutoCreateColumns is set to false, we never detect the properties/DataColumns for the data source and therefore, we cannot assign a default editor.

    When AutoCreateColumns is set to false, it is recommended to specify the CellEditors explicitly to ensure that the InsertionRow (or in your case, a new row with ‘null’ values ) can be edited normally, otherwise, we cannot detect the “intended” data type. ( Note: you would see the same problem if the value of one of your data item has ‘null’ content ).

    Hope this explanation brings the appropriate clarifications.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 4417 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.