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

How to display celleditor only on insertionrow?

Sort Posts: Previous Next
  •  05-13-2008, 2:47 PM Post no. 12218

    How to display celleditor only on insertionrow?

    Hi,

     

    I'm currently stuck a little bit.

    My current grid has a column which has to be readonly (not changeable), so I define it as readonly.

    But, when the user click on the insertionrow a cell editor should appear to provide a selection of values.

    But being readonly the column cannot display a cell editor.

     

    I've tried to overcome this by overwriting BeginEdit and cancel it if the user selects the "readonly" column,

    but by clicking on another column the full row is in edition mode and the user can change the value of

    the "readonly" column too.

     

    What's the simplest way to supply a cell editor of a readonly column only in the insertionrow?

     

    Thanks,

    Michael

  •  05-13-2008, 5:20 PM Post no. 12225 in reply to 12218

    Re: How to display celleditor only on insertionrow?

    Set the InsertonRow's ReadOnly property to false.

    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  05-14-2008, 9:27 AM Post no. 12247 in reply to 12225

    Re: How to display celleditor only on insertionrow?

    Hi Jenny,

     

    thanks for your answer, but that does not do the trick.

    If the column has ReadOnly=true, setting InsertionRow.ReadOnly=false will have no effect.

    Here's the code I use:

     

    private void InitializeGrid()

    {

    jwpGridTZBJeEART.Columns.Create("SubEnergyKind", Core.Resources.Energy.SubEnergyKind(), "E_ART1", new JWPGrid.Editors.JWPDataGridControlComboBoxCellEditor(_subEnergyKindDataSource)).ReadOnly = true;

     

    // Create the insertion row.

    DataTemplate NewDataTemplate = new DataTemplate();

    FrameworkElementFactory NewInsertionRow = new FrameworkElementFactory(typeof(JWPDataGrid.InsertionRow));

    NewInsertionRow.SetValue(JWPDataGrid.InsertionRow.ReadOnlyProperty, false);

    NewDataTemplate.VisualTree = NewInsertionRow;

    jwpGridTZBJeEART.View.FixedHeaders.Add(NewDataTemplate);

     

    _dataGridCollectionView = jwpGridTZBJeEART.CreateDataGridCollectionView(_facade.saldo_tzbDataTable.DefaultView, typeof(DataRowView));

    _dataGridCollectionView.ItemProperties.Add(new JWPDataGrid.DataGridItemProperty("SubEnergyKind", "E_ART1", typeof(string), true));

     

    jwpGridTZBJeEART.InitializingInsertionRow += new EventHandler<Xceed.Wpf.DataGrid.InitializingInsertionRowEventArgs>(jwpGridTZBJeEART_InitializingInsertionRow);

    }

     

    void jwpGridTZBJeEART_InitializingInsertionRow(object sender, Xceed.Wpf.DataGrid.InitializingInsertionRowEventArgs e)

    {

    e.InsertionRow.Cells["SubEnergyKind"].CellValidationRules.Add(new SubEnergyKindValidationRule(jwpGridTZBJeEART));

    e.InsertionRow.ReadOnly = false;

    }

    "Columns.Create" is a little method I wrote to simplify column creation.

    The InitializingInsertionRow-Event will only fire if the insertion row switches to edition mode.

    The ComboBox-CellEditor shall only be active in the insertion row.

     

    Any other options I can try?

     

    Thanks,

    Michael 

     

     

     

     

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