Welcome to the Xceed Community | Help
Community Search  

adding combobox with xceed data grid

Sort Posts: Previous Next
  •  07-03-2007, 12:03 AM Post no. 8619

    adding combobox with xceed data grid

    Hi,

    I have used xceed datagrid in my project. And I am binding data with this
    grid using xmldataprovider. Now I want to add combo box in columns. Not able
    to add combobox . can you pleae help me how to add combo box and binding
    that combobox with xml.
    Can check the code I have used

    <Page x:Class="DataGridApplication.GridApplication">
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"

    Title="GridApplication">

    <!--using xml inside xmal to bind with grid-->
    <Page.Resources>

    <XmlDataProvider x:Key="MyData" XPath="Info">

    <x:XData>
    <Info xmlns="">
    <List>
    <Photo> No </Photo>
    <First> abc </First>
    <Last>xnm</Last>
    <BirthDate>1983</BirthDate>
    <Address>Bangalore</Address>
    <City>Bangalore</City>
    <Region>India</Region>
    <Country>India</Country>
    <PostalCode>56093</PostalCode>
    <HomePhone>3243234</HomePhone>
    <Notes>njh</Notes>
    </List>
    </Info>
    </x:XData>
    </XmlDataProvider>

    </Page.Resources>
    <xcdg:DataGridControl x:Name="grid"
    CellEditorDisplayConditions="None"
    EditTriggers="None"
    ReadOnly="True"
    ItemScrollingBehavior="Immediate"
    NavigationBehavior="RowOnly"
    ItemsSource="{Binding Source={StaticResourceMyData} , XPath=List}"
    AutoCreateColumns="False">
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName="Photo"

    Title="Photo"

    MinWidth="65"

    MaxWidth="65"

    DisplayMemberBinding="{Binding XPath=Photo}" />

    <xcdg:Column FieldName="First"

    Title="First Name IsMainColumn="True"
    MinWidth="125"
    MaxWidth="125"
    DisplayMemberBinding="{Binding XPath=First}"
    >

    <xcdg:Column.CellEditor>

    <xcdg:CellEditor>
    <xcdg:CellEditor.EditTemplate>
    <DataTemplate> <ComboBox
    IsSynchronizedWithCurrentItem="True" SelectedValue="{Binding XPath=First,
    Mode=TwoWay}">

    <ComboBoxItem
    Content="Full" Width="Auto" Height="Auto"/>

    <ComboBoxItem
    Content="Partial" Width="Auto" Height="Auto"/>

    <ComboBoxItem
    Content="Low" Width="Auto" Height="Auto"/>

    </ComboBox>
    </DataTemplate>

    </xcdg:CellEditor.EditTemplate>
    <xcdg:CellEditor.ActivationGestures>
    <xcdg:KeyActivationGesture
    Key="Right"/>
    <xcdg:KeyActivationGesture
    Key="Left"/>
    </xcdg:CellEditor.ActivationGestures>
    </xcdg:CellEditor>

    </xcdg:Column.CellEditor>

    </xcdg:Column>

    <xcdg:Column FieldName="Last"

    Title="Last Name"

    MinWidth="125"

    MaxWidth="125"

    DisplayMemberBinding="{Binding XPath=Last}"
    />

    <xcdg:Column FieldName="BirthDate"

    Title="Birth Date"

    MinWidth="90"

    MaxWidth="90"

    DisplayMemberBinding="{Binding XPath=BirthDate}"/>

    <xcdg:Column FieldName="Address"

    Title="Address"

    MinWidth="125"

    MaxWidth="125"

    DisplayMemberBinding="{Binding XPath=Address}"/>



    <xcdg:Column FieldName="City"

    Title="City"

    MinWidth="125"

    MaxWidth="125"
    DisplayMemberBinding="{Binding XPath=City}" >

    </xcdg:Column>

    <xcdg:Column FieldName="Region"

    Title="Region"

    MinWidth="125"

    MaxWidth="125"

    DisplayMemberBinding="{Binding XPath=Region}"/>

    <xcdg:Column FieldName="Country"

    MinWidth="125"

    MaxWidth="125"

    DisplayMemberBinding="{Binding XPath=Country}"/>

    <xcdg:Column FieldName="PostalCode"

    Title="Postal Code"

    MinWidth="125"

    MaxWidth="125"

    DisplayMemberBinding="{Binding XPath=PostalCode}"/>

    <xcdg:Column FieldName="HomePhone"

    Title="Home Phone"

  •  07-03-2007, 7:39 AM Post no. 8620 in reply to 8619

    Re: adding combobox with xceed data grid

    Hi ,

    Can anybody tell me how i can bind xml data with combobox used in Xceeddata grid column?

    is there any other way to bind data with combobox?


    thanks in advance

    kk
  •  07-03-2007, 8:51 AM Post no. 8621 in reply to 8620

    Re: adding combobox with xceed data grid

    Looking at your code, I can see several small problems:

    - You need to use the "CellEditorBinding" Markup extension to correctly bind your editor to the cell's value.
    - For the editor to display, you will need to either have a CellEditorDisplayConditions or an EditTriggers which is not "None".
    Marc Laroche
    Software Developer
    Xceed Software Inc.


    I don’t suffer from insanity, I enjoy every minute of it. - Unknown
  •  07-04-2007, 1:48 AM Post no. 8622 in reply to 8621

    Re: adding combobox with xceed data grid

    Its not working . can you please tell me in detail what changes should be done in my code?

    Thanks in advance
    kk
  •  07-04-2007, 8:48 AM Post no. 8623 in reply to 8622

    Re: adding combobox with xceed data grid

    <xcdg:DataGridControl x:Name="grid"
    CellEditorDisplayConditions="None"
    EditTriggers="None" />

    Those 2 properties need NOT to be "None" so that the editor can be displayed... please refer to the documentation of those properties for a list of possible values.

    <ComboBox
    IsSynchronizedWithCurrentItem="True" SelectedValue="{Binding XPath=First,
    Mode=TwoWay}">

    Instead of using a {Binding ...} to bind the editor to the Cell, you need to use {xcdg:CellEditorBinding} ... The syntax as you indicated is not supported, please refer to the documentation of CellEditorBindingExtension for details and to the "Advanced Concepts / Custom Cell Editors" topic in the documentation.

    If you have further problems, you will need to provide a more detailed explanation of what they are...
    Marc Laroche
    Software Developer
    Xceed Software Inc.


    I don’t suffer from insanity, I enjoy every minute of it. - Unknown
  •  07-21-2008, 12:46 AM Post no. 13644 in reply to 8620

    adding combobox with xceed data grid

     

    i want to add Combo box into Xceed Grid.please help me...
  •  08-04-2008, 10:32 PM Post no. 13875 in reply to 13644

    Re: adding combobox with xceed data grid

    Can someone please answer this?

    Adding a ComboBox is sooo difficult. I have read and understand the Solid Foundation sample but I want to use a DataTable that is NOT in the Application.Current, it's on the page. And do we have to create all this dictionary stuff - for EVERY type of combobox - just to display the meaningful value when not in edit mode! Gee whiz!

     

  •  08-05-2008, 10:04 PM Post no. 13915 in reply to 13875

    Re: adding combobox with xceed data grid

    UserControl.Resources of UserControl or Windows.Resources of Window

    <DataTemplate x:Key="colReinstatementType">
                <!---  Combobox will come HERE!! -->
    </DataTemplate>

     DataGrid

     <my1:DataGridControl 
                        Name="myDataGrid"
                        AutoCreateColumns="False"
                        NavigationBehavior="RowOnly"                  
                        ItemsSource="{Binding Source={StaticResource viewModel}, Path=MyData}" Margin="12,135,9,69" SelectionMode="Single" ItemScrollingBehavior="Deferred">
                        <xcdg:DataGridControl.View>
                            <xcdg:TableView UseDefaultHeadersFooters="False" ShowFixedColumnSplitter="False">
                                <xcdg:TableView.FixedHeaders>
                                    <DataTemplate>
                                        <xcdg:ColumnManagerRow />
                                    </DataTemplate>
                                </xcdg:TableView.FixedHeaders>
                            </xcdg:TableView>
                        </xcdg:DataGridControl.View>
                        <my1:DataGridControl.Columns>
                            <!-- The column "Status" should be Unbound Column but it can't be done with Xceed Datagrid so the bound column has to be used but it won't be using in DataTemplate. Note: This is a trick. -->
                            <my1:Column FieldName="Field1" Title="Status" Width="50" CellContentTemplate="{StaticResource colReinstatementType}">                           
                            </my1:Column>
                        </my1:DataGridControl.Columns>
                    </my1:DataGridControl>

     

    If you are following this way, you will be able to show any control in Grid Column. 

    But How can you get the reference of those controls inside datagrid?  I mean, how will you read the value of those controls that you put inside the Grid Column after the user is selecting?

    For this case, we can use Visual Tree Helper to loop through each and every DataGrid Row and get the reference of control. (This can be done)  But the problem comes here. Xceed Datagrid doesn't show all rows on startup. That means, if the user scrolls the scrollbars then the rows will be created dynamically on the fly. So, we can't get all rows. :( Please read this post for more details about that problem. http://xceed.com/CS/forums/post/13798.aspx

     

  •  08-11-2008, 4:38 PM Post no. 14002 in reply to 13915

    Re: adding combobox with xceed data grid

    Reply in this thread:

    http://xceed.com/CS/forums/14001/ShowThread.aspx


    Odi Kosmatos
    VP, R&D, Xceed
  •  10-17-2008, 5:02 AM Post no. 16183 in reply to 8619

    Re: adding combobox with xceed data grid

    ---------------RESOURCES------------

     <xcdg:CellEditor x:Key="combobox">
                <xcdg:CellEditor.EditTemplate>
                    <DataTemplate>
                        <ComboBox Width="80"
                                          SelectValue="{xcdg:CellEditorBinding}" >
                        </ComboBox>
                    </DataTemplate>
                </xcdg:CellEditor.EditTemplate>
            </xcdg:CellEditor>

    --------------DATAGRIDCONTROL------------------

    <xcdg:DataGridControl Name="DATAGRIDCONTROLname"
                                                ItemsSource="{Binding Path=Table}" >
                <xcdg:DataGridControl.Columns>
                    <xcdg:Column FieldName="FieldName"

                                          VisiblePosition="" 

                                          CellEditor="{StaticResource combobox}"/>          

    </xcdg:DataGridControl.Columns>

     

     

     

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.