javascriptangulardevexpressdevextremedevextreme-angular

Devextreme datagarid : default value of column cells when whith lookup


i'am using devextreme datagrid under my Angular 5 app.

My datagrid looks like this :

<dx-data-grid
    #positionsDataGrid
    id="positionsDataGrid"
    [dataSource]="positionsDataSource"
    keyExpr="id"
    [allowColumnReordering]="true"
    [showBorders]="true"
    loadPanel="false">

    <dxo-paging [enabled]="true"></dxo-paging>
    <dxo-editing
      mode="row"
      [allowUpdating]="true"
      [allowDeleting]="true"
      [allowAdding]="true">
    </dxo-editing>

    <dxi-column dataField="id" caption="ID" [allowEditing]="false" [visible]="false"></dxi-column>
    <dxi-column dataField="Cuid" caption="name" [allowEditing]="false"></dxi-column>

    <dxi-column
      dataField="storeName"
      caption="Boutique"
      [width]="400"
      [setCellValue]="preSelectShop">
      <dxo-lookup>
        <[dataSource]="shops">
        <displayExpr="storeName>
        <valueExpr="ID">>
      </dxo-lookup>
    </dxi-column>

  </dx-data-grid>

i'am loading initial data from a WS (under 'positionsDataSource' var ) :

  [{
    'id': '2',
    'name': 'test',
    'storeName': 'ABBEVILLE',
  }]

the default values cells of the column "storeName" din't appear

(but when EDIT mode ; the values re-appear)

My purpose is how to make the default values appear.

Suggestions?


Solution

  • Use this code, it will work:

    onInitNewRow: function (e) {
            e.data.test= 'ABBEVILLE';
          e.component.__addingStart = true;
        },