Welcome to the Xceed Community | Help
Community Search  
More Search Options

How do you use a cell editor only in the InsertionRow?

Sort Posts: Previous Next
  •  04-22-2009, 11:03 PM Post no. 20482

    How do you use a cell editor only in the InsertionRow?

    I've been trying to solve this for the past 3 hours and I cannot figure it out, unless I resort to a full blown template for the InsertionRow. My problem is simple: I have a column in a grid which is normally read-only but when adding a new row I would like to display a combobox in that column so that an user will be able to pick up a value. Again, once the row gets created that particular property becomes read-only. I though it would be easy, maybe it is but I can't figure it out. Appreciate any response.

     

    Thanks,

    Eugen

  •  04-23-2009, 9:56 PM Post no. 20522 in reply to 20482

    Re: How do you use a cell editor only in the InsertionRow?

    I had this same problem, except *all* of my columns were read only.  I ended up doing a popup that showed some controls for the intitial data.  No matter how I templated the insert row, all controls in the template were read only and unusable.
  •  04-24-2009, 5:53 PM Post no. 20545 in reply to 20522

    Re: How do you use a cell editor only in the InsertionRow?

    You may be able to do it this way:

    first subclass InsertionRow and InsertionCell

        public class MyInsertionCell : Xceed.Wpf.DataGrid.InsertionCell
        {
            public MyInsertionCell()
                : base()
            {
            }
           
            protected override CellEditor GetCellEditor()
            {
              Xceed.Wpf.DataGrid.DataGridControl parentDataGrid = Xceed.Wpf.DataGrid.DataGridControl.GetParentDataGridControl(this);
                 Xceed.Wpf.DataGrid.CellEditor _yourCellEditor = parentDataGrid.FindResource("YourCellEditor") as Xceed.Wpf.DataGrid.CellEditor;
                if (this.FieldName.CompareTo("Column1") == 0)
                {
                  return _yourCellEditor;
                    }
       // and so on for the other columns
                return base.GetCellEditor();
            }
        }

     class MyInsertionRow : Xceed.Wpf.DataGrid.InsertionRow
        {
            protected override Cell CreateCell(Column column)
            {
                return new MyInsertionCell();
            }

            protected override bool IsValidCellType(Cell cell)
            {
                return cell is MyInsertionCell;
            }
        }
     
     Then in your XAML for the DataGridControl do the following where local is the namespace where the above classes are defined (this example uses the fixed footers but you can define yours where ever you want it)
     <xcdg:TableView.FixedFooters>
      <DataTemplate>
       <local:MyInsertionRow />
      </DataTemplate>
     </xcdg:TableView.FixedFooters>

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