Home Forums WPF controls Xceed DataGrid for WPF Editing my DataGrid

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

    Hi there,
    I have a datagrid bound to an XML datasource.
    I set the following property:
    EditTriggers=”BeginEditCommand,ActivationGesture,ClickOnCurrentCell,CellIsCurrent”
    Nevertheless, when i click on a cell, I can’t modify it.
    What did i forget?
    Thanks for help.

    Imported from legacy forums. Posted by valentin (had 11338 views)

    Xceed Support
    Member
    Post count: 5658

    You will need to provide a cell editor for each of the Columns, as data type cannot be resolved when we are bound to XML data.

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

    User (Old forums)
    Member
    Post count: 23064

    Okay,
    I did that.
    Nevertheless, when the cell i’m writing in loose focus, all data inside are removed.
    I can’t create an entire row this way.
    Thanks for help 🙂

    Imported from legacy forums. Posted by valentin (had 394 views)

    User (Old forums)
    Member
    Post count: 23064

    This was solved.
    While i was reading the doc, i saw that the “AddingNewDataItem” was not raised when using an XML DataSource.
    Is there a way to mimick this event?
    I need to add items written in my InsertionRow by the user to my XmlDataSource.
    Is there an event to help me ?
    Thanks for help !

    Sad

    Imported from legacy forums. Posted by valentin (had 330 views)

    Xceed Support
    Member
    Post count: 5658

    What you could do it use a DataTable to read the content of the XML file (Datatable.ReadXml method). Once you have your XML data in the datatable, assign the datatable’s DefaultView property to a collectionviewsource’s Source property.

    Your insertion row will function and allow you to add items to the datatable, which you can then write back into your xml file using the table’s WriteXml method.

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

    User (Old forums)
    Member
    Post count: 23064

    Thanks for your help 🙂
    I’ll try that now !

    Imported from legacy forums. Posted by valentin (had 513 views)

    Xceed Support
    Member
    Post count: 5658

    I use this technique in an application I created for the documentation snippets. So far, it works quite well. If you h ave no relationships in your xml file, I would suggest you use the DataGridCollectionViewSource rather than the standard CollectionViewSource; it gives you more options.

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

    User (Old forums)
    Member
    Post count: 23064

    I get this error :
    “DataTable does not support schema inference from Xml”
    while trying to read my XmlFile.
    This is the same file i used to bind to my Datagrid so i don’t know what’s wrong!
    Can you help?
    Thanx,
    Sad

    Imported from legacy forums. Posted by valentin (had 577 views)

    Xceed Support
    Member
    Post count: 5658

    Here is the code that I use. It should help you out 🙂

    <code>
    public partial class App : System.Windows.Application
    {
    protected override void OnStartup( StartupEventArgs e )
    {
    base.OnStartup( e );
    }

    static App()
    {
    m_snippetsDataSet = new SnippetsDataSet();

    m_snippetsDataSet.ReadXml( @”..\..\Snippets.xml” );
    m_snippets = m_snippetsDataSet.Snippets;
    }

    public static void SaveData()
    {
    m_snippetsDataSet.WriteXml( @”..\..\Snippets.xml” );
    }

    public static DataView SnippetView
    {
    get
    {
    return m_snippets.DefaultView;
    }
    }

    private static SnippetExplorer.SnippetsDataSet.SnippetsDataTable m_snippets = null;
    private static SnippetsDataSet m_snippetsDataSet = null;
    }
    }
    </code>

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

    User (Old forums)
    Member
    Post count: 23064

    Ok, thanks
    I (finally) successfully fill my DataSet.
    Then I used a datatable to retrieve the first dim of this dataset.
    Nevertheless, I can’t use that to fill my Datagrid.

    MyDataGrid.ItemsSource = MyDataTable; does not work.
    Any thoughs ?!

    You’re really patient with me 🙂
    Thank you really, it really helps me.
    I’m new to Xceed’ Datagrid manipulation and it’s quite difficult for me now !

    Sad

    Imported from legacy forums. Posted by valentin (had 777 views)

    Xceed Support
    Member
    Post count: 5658

    Start by creating an instance of the DataGridCollectionView (or DataGridCollectionViewSource in XAML) class and set its Source property to MyDataTable.DefaultView.

    Next, set the instance of DGCV to the ItemsSource property of the grid.

    For example:

    DataGridCollectionView view = new DataGridCollectionView( MyDataTable.DefaultView );
    MyDataGrid.ItemsSource = view;

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

    User (Old forums)
    Member
    Post count: 23064

    Each time your answer is full of insight, thank you for that 🙂
    There is a last thing that confuses me:
    When I use AutoCreateColumns to create my columns, everything runs smoothly.
    But when i create myself my columns, data does not appear.
    Here is a sample code:

    <DataTemplate>
    <TextBlock>
    <TextBlock.Text>
    <Binding Path=”Code”/>
    </TextBlock.Text>
    </TextBlock>
    </DataTemplate>

    <xcdg:DataGridControl
    Name=”MyDataGrid”
    EditTriggers=”RowIsCurrent,CellIsCurrent”
    CellEditorDisplayConditions=”CellIsCurrent,RowIsCurrent”
    AutoCreateColumns=”False”
    ReadOnly=”False”>

    <xcdg:Column ReadOnly=”False” CellEditor=”{StaticResource DefaultEditor}” Title=”Code” IsMainColumn=”True” FieldName=”Code” Width=”100″ CellContentTemplate=”{StaticResource codeDataTemplate}” />

    The Xml files looks like:

    <?xml version=”1.0″ encoding=”utf-8″?>
    <CodesX>
    <CodeX>
    <Code>A</Code>
    <Encais>False</Encais>

    </CodeX>
    </CodesX>

    I tried some things in my DataTemplate such as
    ->Changing Path to Xpath
    -> Path=”CodeX/Code”
    -> Path=”CodesX/CodeX/Code”

    Nothing ran correctly: no data were displayed.
    Can you tell me what’s wrong ?
    It’s the last thing that confuses me !
    Thanks for all your help,

    Sad

    Imported from legacy forums. Posted by valentin (had 706 views)

    User (Old forums)
    Member
    Post count: 23064

    The XML file was badly displayed:

    <?xml version=”1.0″ encoding=”utf-8″?>
    <CodesX>

    <CodeX>
    <Code>A</Code>
    <Encais>False</Encais>
    </CodeTVA>

    🙂

    Imported from legacy forums. Posted by valentin (had 471 views)

    User (Old forums)
    Member
    Post count: 23064

    Something seems to be wrong when adding Xml …

    Imported from legacy forums. Posted by valentin (had 888 views)

    Xceed Support
    Member
    Post count: 5658

    You need to set the column’s DisplayMemberBinding property when manually creating your columns.

    For example: DisplayMemberBinding=”{Binding ColumnName}”

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

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