Welcome to the Xceed Community Sign in | Join | Help
Community Search  

Code example for updating datasource

Page 1 of 2 (24 items)   1 2 Next >
Sort Posts: Previous Next
  •  09-06-2008, 2:26 PM Post no. 14969

    Code example for updating datasource

    Does anyone have a code example of handling edits in the datagrid????? There is zero documentation on this in the samples and help, all the samples do not update the datasource permanently just in the grid.

     

    Angry 

     

     

     

     

     

  •  09-08-2008, 8:22 AM Post no. 14982 in reply to 14969

    Re: Code example for updating datasource

    The Routed Edit Events page in the documentation demonstrates how to handle the events. As for updating the source, I do not have any examples because of the wide number of possible data sources. Basically, you should be handling the EditEnded event and update your source there.

    If you do not know how to update the source, let me know what it is and I will throw together an example for you.


    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  09-08-2008, 8:30 AM Post no. 14986 in reply to 14982

    Re: Code example for updating datasource

    It will be better if u give a example on how to update database ....

    Thanx.....

  •  09-08-2008, 8:32 AM Post no. 14987 in reply to 14986

    Re: Code example for updating datasource

    What is the TYPE of the data base? I cannot tell you how to update it without knowing what it is.
    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  09-08-2008, 12:06 PM Post no. 15022 in reply to 14987

    Re: Code example for updating datasource

    SQL 2005.

     

    I got it narrowwed down to this event:   DataGridCollectionViewSource_EditCommitted but i dont know how to access the cell information. 

  •  09-08-2008, 12:54 PM Post no. 15026 in reply to 15022

    Re: Code example for updating datasource

    I have explained in the previous replies that you would need to use the EditEnded event, which is a routed event defined on the Cell class, if you want to access the value of the cell whose value was edited. If you want to use the EditCommitted event, then you can access the data item through the e.Item property received in the event args.

    If you are using SQL Server 2005, then I will assume you are using ADO.NET datasets; therefore, you can use the  AcceptChanges method to commit modifications. This page (http://msdn.microsoft.com/en-us/library/ceab2k93.aspx) should provide you with the required information.


    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  09-08-2008, 2:11 PM Post no. 15031 in reply to 15026

    Re: Code example for updating datasource

    Thanks. How would i access an ID field that is hidden as a column in the selected row? I need the id for the update.

     

     

  •  09-08-2008, 2:28 PM Post no. 15033 in reply to 15026

    Re: Code example for updating datasource

    Jenny:

    I have explained in the previous replies that you would need to use the EditEnded event, which is a routed event defined on the Cell class, if you want to access the value of the cell whose value was edited. If you want to use the EditCommitted event, then you can access the data item through the e.Item property received in the event args.

    If you are using SQL Server 2005, then I will assume you are using ADO.NET datasets; therefore, you can use the  AcceptChanges method to commit modifications. This page (http://msdn.microsoft.com/en-us/library/ceab2k93.aspx) should provide you with the required information.

     

    e.Item gives me System.Data.DataRow not the value of the field being edited, any other ideas?

    Sad 

     

     

     

     

  •  09-08-2008, 7:53 PM Post no. 15043 in reply to 15033

    Re: Code example for updating datasource

    In my previous replies, I have stated that the EditEnded event defined on the Cell class and NOT the EditCommitted event defined on the DataGridCollectionView class should be used if you want to know the value of the cell that was edited.

    That said, if you insist on using the EditCommitted event, you will need to know the name of the cell that was being edited and then access the corresponding cell through the data item (System.Data.DataRow) you are receiving in the event args (of the EditCommitted event). For example:

    ( ( DataRow )e.Item )["NameOfTheCell"]; 

    You can refer to the Edit Routed Events (http://doc.xceedsoft.com/products/XceedWpfDataGrid/Handling_Edit_Events.html) topic in the documentation for examples on how to use the EditEnded event OR you can refer to the DataGridCollectionView Edit Events topic (http://doc.xceedsoft.com/products/XceedWpfDataGrid/Editing_Data_CollectionView.html) for information on the EditCommitted event.


    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  09-08-2008, 8:07 PM Post no. 15047 in reply to 15043

    Re: Code example for updating datasource

    Jenny:

    In my previous replies, I have stated that the EditEnded event defined on the Cell class and NOT the EditCommitted event defined on the DataGridCollectionView class should be used if you want to know the value of the cell that was edited.

    That said, if you insist on using the EditCommitted event, you will need to know the name of the cell that was being edited and then access the corresponding cell through the data item (System.Data.DataRow) you are receiving in the event args (of the EditCommitted event). For example:

    ( ( DataRow )e.Item )["NameOfTheCell"]; 

    You can refer to the Edit Routed Events (http://doc.xceedsoft.com/products/XceedWpfDataGrid/Handling_Edit_Events.html) topic in the documentation for examples on how to use the EditEnded event OR you can refer to the DataGridCollectionView Edit Events topic (http://doc.xceedsoft.com/products/XceedWpfDataGrid/Editing_Data_CollectionView.html) for information on the EditCommitted event.

     

    None of your Previous statements have solved my problem so Im going to keep asking until you answer it correctly, you mentioned previously you would supply us with a code snippet and you never did so, I need answers not suggestions, post a fully working block of code that does what we need. You did however say the e.Item would get me what I needed did you not??????? It is a simple issue we need resolved.

     

     

  •  09-08-2008, 8:22 PM Post no. 15049 in reply to 15043

    Re: Code example for updating datasource

    I am trying to subscribe to the edit events but the code in the example doesn't seem to be right. I get the error "Cannot find the Style Event 'EditBeginning' on the type 'Xceed.Wpf.DataGrid.Cell'." What am I missing?


    <Window x:Class="DFAT.Metadata.WPF.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="auto" Width="auto"

            Loaded="OnLoaded"
            >
        <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
            <Grid.Resources>

                <Style TargetType="{x:Type xcdg:DataGridControl}">
                    <EventSetter Event="xcdg:Cell.EditBeginning"
                         Handler="EditBeginning" />
                    <EventSetter Event="xcdg:Cell.EditBegun"
                         Handler="EditBegun" />
                </Style>

                <Style TargetType="{x:Type xcdg:DataRow}">
                    <EventSetter Event="xcdg:Cell.EditBeginning"
                          Handler="EditBeginning" />
                    <EventSetter Event="xcdg:Cell.EditBegun"
                          Handler="EditBegun" />

                </Style>


            </Grid.Resources>
            <xcdg:DataGridControl x:Name="OrganisationalUnitsGrid"
                            ValidationMode="CellEndingEdit"
                            CellEditorDisplayConditions="RowIsBeingEdited"
                            >
                <xcdg:DataGridControl.Columns>
                    <xcdg:Column FieldName="Name" IsMainColumn="True" Title="Name" />
                    <xcdg:Column FieldName="Acronym" Title="Acronym" />
                    <xcdg:Column FieldName="EntityId" ReadOnly="True" Title="EntityId" Visible="False" />
                    <xcdg:Column FieldName="ExtensionData" ReadOnly="True" Title="ExtensionData" Visible="False" />
                </xcdg:DataGridControl.Columns>
                
                <xcdg:DataGridControl.View>
                    <xcdg:TableView>
                        <xcdg:TableView.Theme>
                            <xcdg:Office2007BlueTheme />
                        </xcdg:TableView.Theme>
                    </xcdg:TableView>
                </xcdg:DataGridControl.View>
            </xcdg:DataGridControl>
        </Grid>
    </Window>

  •  09-08-2008, 10:57 PM Post no. 15050 in reply to 15049

    Re: Code example for updating datasource

    Peter:

    I am trying to subscribe to the edit events but the code in the example doesn't seem to be right. I get the error "Cannot find the Style Event 'EditBeginning' on the type 'Xceed.Wpf.DataGrid.Cell'." What am I missing?


    <Window x:Class="DFAT.Metadata.WPF.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="auto" Width="auto"

            Loaded="OnLoaded"
            >
        <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
            <Grid.Resources>

                <Style TargetType="{x:Type xcdg:DataGridControl}">
                    <EventSetter Event="xcdg:Cell.EditBeginning"
                         Handler="EditBeginning" />
                    <EventSetter Event="xcdg:Cell.EditBegun"
                         Handler="EditBegun" />
                </Style>

                <Style TargetType="{x:Type xcdg:DataRow}">
                    <EventSetter Event="xcdg:Cell.EditBeginning"
                          Handler="EditBeginning" />
                    <EventSetter Event="xcdg:Cell.EditBegun"
                          Handler="EditBegun" />

                </Style>


            </Grid.Resources>
            <xcdg:DataGridControl x:Name="OrganisationalUnitsGrid"
                            ValidationMode="CellEndingEdit"
                            CellEditorDisplayConditions="RowIsBeingEdited"
                            >
                <xcdg:DataGridControl.Columns>
                    <xcdg:Column FieldName="Name" IsMainColumn="True" Title="Name" />
                    <xcdg:Column FieldName="Acronym" Title="Acronym" />
                    <xcdg:Column FieldName="EntityId" ReadOnly="True" Title="EntityId" Visible="False" />
                    <xcdg:Column FieldName="ExtensionData" ReadOnly="True" Title="ExtensionData" Visible="False" />
                </xcdg:DataGridControl.Columns>
                
                <xcdg:DataGridControl.View>
                    <xcdg:TableView>
                        <xcdg:TableView.Theme>
                            <xcdg:Office2007BlueTheme />
                        </xcdg:TableView.Theme>
                    </xcdg:TableView>
                </xcdg:DataGridControl.View>
            </xcdg:DataGridControl>
        </Grid>
    </Window>

    For some unknown reason answers on this subject are hard to come by. 

  •  09-08-2008, 11:34 PM Post no. 15051 in reply to 15050

    Re: Code example for updating datasource

    Yeah, I'm pouring through the help...and I admit I am a bit of a noob, but this should be easier. 

    A complete example that shows all the bits and pieces wired up would be useful but the documentation tends to stop at the xaml. I would like to see the whole picture with the northwind database using WCF and LINQ to SQL.

     Having said that I think the product looks professional and I am just having some teething problems with it but I would like to know why the example given in help doesn't work for me.

     I am using the Express version by the way.

  •  09-08-2008, 11:51 PM Post no. 15052 in reply to 15051

    Re: Code example for updating datasource

    Interestingly this code fires the handlers in my code behind

            <Style TargetType="{x:Type xcdg:DataRow}">
                <EventSetter Event="MouseEnter"
                   Handler="DataRowMouseEnter"/>

                <EventSetter Event="MouseLeave"
                   Handler="DataRowMouseLeave"/>
            </Style>

    But this doesn't work

             <Style TargetType="{x:Type xcdg:DataRow}">
                <EventSetter Event="xcdg:Cell.EditBeginning"
                     Handler="EditBeginning" />
                <EventSetter Event="xcdg:Cell.EditBegun"
                     Handler="EditBegun" />
            </Style>

    My Guess is that they have changed the API without updating the documentation. I looked the cell methods page http://doc.xceedsoft.com/products/XceedWpfDataGrid/Xceed.Wpf.DataGrid~Xceed.Wpf.DataGrid.Cell_members.html it has these events documented. So I don't know what it is that I am doing wrong.

     

     

     

  •  09-09-2008, 9:01 AM Post no. 15064 in reply to 15052

    Re: Code example for updating datasource

    Yeah i cant get it to work either, only one person answers questions on this board. I have 35 days left on my evaluation so if i cant get it done before then Im not buying it.
Page 1 of 2 (24 items)   1 2 Next >
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.