Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
525
AddNewRowCell in CellExitedEditMode
posted

Hi,

I'm having some problems retrieving the value of a cell in the CellExitedEditMode event using the AddNewRowFeature.

Value's of a cell that have a column which key is linked to a field in my business object on the first level are retrieved correctly (eg executorFullName below, e.Cell.Value contains a string)
     <igGrid:TextColumn IsSortable="False" IsFixed="Left" HeaderText="Executor" Key="executorFullName" />

However: values's of a cell that have a column which key is linked to a fied in my business object on the second level are not retrieved correctly (it is null)

<igGrid:TextColumn IsSortable="False" IsFixed="Left" HeaderText="Home Base" Key="oHomeBase.description" />

e.Cell.Value of oHomeBase.description is null.

Regular editing of existing records on my grid works perfectly. The above scenario only occurs when using AddNewRow.

Parents
No Data
Reply
  • 6475
    Verified Answer
    posted

    Hi,

    When the grid creates such new objects to use for its needs (such as for AddNewRow feature), it would fire the DataObjectRequested event. You can add an event handler for this event and supply your own "empty" object to use by returning it in e.NewObject event argument. This gives you the ability to do some custom initialization if needed. If you don't do that, then the grid will try to automatically create a new object for you.

    So, you could add a listener for the DataObjectRequested event , create a new object there and set some initial values of its fields:

     private void igGrid_DataObjectRequested(object sender, DataObjectCreationEventArgs e)

    {

    if (e.ObjectType == typeof(MyDataObject))

    {

    MyDataObject newObj = new MyDataObject();

    newObj.oHomeBase = new HomeBase();

    e.NewObject = newObj;

    }

    }
     

    Hope that helps,

Children