UXGrid binding to property navigation (DevForce)- problem with adding new record

6 replies. Last post: June 28, 2011 6:33 AM by Andrzej Sulej
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

Hello

I've prepared example base on your template with DevForce. There is applied model Region +Territory.

In northindmodel.edms I've changed only TerritoryID (of Territory entity) property to Identity.

Constructor of TerritoryViewModel has implemented Region as argument. Base on Region we get property navigation about Territories. 

//public class TerritoryViewModel1 : EditableGridViewModelBase<Territory>
public TerritoryViewModel1(Region region)
            : base()
        {
            _region = region;
            Items = region.Territories;
                
        }

Property items is binding to UXGrid.

The problem is when we try to add new territory to initial region. 

It's necessery to set Region property in Territory entity. We can do that in 3-way:

1. override method ExecutePrepareNewRow (in my example it's Territory1 on menu)

protected override void ExecutePrepareNewRow(object parameter)
        {
            base.ExecutePrepareNewRow(parameter);
            this.NewItem.Region = _region;
        }

 Problem: when I click on new row , the same one appear on bottom


2. override method ExecuteInsertRow (in my example it's Territory2 on menu)

protected override void ExecuteInsertRow(object parameter)
        {
            ((Territory)parameter).Region = _region;
            //this.NewItem.Region = _region;
            base.ExecuteInsertRow(parameter);
        }

 Problem : after insert we get double record on list but one of them couldn't be selected


3. override method ExecuteValidateRow

protected override void ExecuteValidateRow(object parameter)
        {
            ((Territory)parameter).Region = _region;
            base.ExecuteValidateRow(parameter);
        }

 This is one solution which working properly


Could you investigate why 1 and 2 solution not working ?


Kind Regards

Andrzej

All times are GMT -5. The time now is 2:20 PM.
Previous Next