Home Forums WPF controls Xceed DataGrid for WPF ValueTranslate in a column with a combobox

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

    I have a grid that has a column which uses a combobox as it’s editor, the combobox is populated from a database and has a two fields (an ID and a Description), the grid column’s actual value will be the ID field but i want it to display the description field from the combo box. I can get the desired result by using the same datatemplate for the CellEditor and CellContentTemplate properties of the column but this shows the combo’s dropdown button on every row.

    is there a better way to do this…

    Imported from legacy forums. Posted by Alan (had 2856 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,

    In the SolidFoundation Sample Application, provided with the Xceed DataGrid for WPF, we already implemented something exactly as you need.

    I suggest taking a look at the sample to help you integrate the same functionality to your application.

    In the MainPage.xaml of the sample, we define a resource called “employeeDataTemplate” which displays an employee’s information. The “employeeDataTemplate” is then reused by the “employeeCellDataTemplate” (which is assigned to the Column’s CellContentTemplate) and by the “employeeEditor” (CellEditor assigned to the Column’s CellEditor).

    If you have further problems achieving your editor, feel free to post further replies.

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

    User (Old forums)
    Member
    Post count: 23064

    I am trying to do this same thing but I’m having problems. The column always shows up with the ID and if I click the cell, a dropdown appears but it is empty. It doesn’t seem like the items are being added to the ComboBox correctly. Here’s my code:
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”BillingCodeID”>
    <xcdg:Column.CellEditor>
    <xcdg:CellEditor>
    <xcdg:CellEditor.EditTemplate>
    <DataTemplate>
    <DockPanel>
    <ComboBox
    ItemsSource=”{Binding Source={StaticResource BillingCodeData}}”
    IsSynchronizedWithCurrentItem=”True”
    SelectedValuePath=”BillingCodeID” />
    </DockPanel>
    </DataTemplate>
    </xcdg:CellEditor.EditTemplate>
    </xcdg:CellEditor>
    </xcdg:Column.CellEditor>
    </xcdg:Column>
    </xcdg:DataGridControl.Columns>

    Then in my cs file for this Page I have:
    public System.Data.DataTable BillingCodes
    {
    get
    {
    return myDataSet.Tables[“BillingCode”];
    }
    }

    Imported from legacy forums. Posted by Robert (had 4194 views)

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