Grid with foreing key column, change value in code does not change text in grid

Hi,

I have a grid:
<ejs-grid id="grdLicencias" dataSource="@ViewBag.DataSource" allowPaging="true" rowSelected="rowSelected" queryCellInfo="customiseCell" allowSelection="true" toolbarClick="toolbarClick" toolbar=toolbarItems height="270" allowFiltering="true" actionBegin="OnActionBegin">
        <e-grid-editSettings allowEditing="true" mode="Normal"></e-grid-editSettings>
        <e-grid-selectionSettings persistSelection="true"></e-grid-selectionSettings>
        <e-grid-filterSettings type="Menu"></e-grid-filterSettings>
        <e-grid-columns>
            <e-grid-column type="checkbox" width="20" allowFiltering="false"></e-grid-column>
            <e-grid-column field="Id" visible="false" isPrimaryKey="true" allowFiltering="false"></e-grid-column>
            <e-grid-column field="Placa" headerText="Placa" textAlign="Center" width="50" allowEditing="false"></e-grid-column>
            <e-grid-column field="IdTipoLicencia" headerText="Licencia" textAlign="Center" width="70" foreignKeyValue="Tipo" foreignKeyField="Id" dataSource="ViewBag.LicenseTypes"></e-grid-column>
            <e-grid-column field="FechaActivacionLicencia" headerText="Inicio" textAlign="Center" type="date" format="yyyy-MM-dd" width="50" allowFiltering="false" allowEditing="false"></e-grid-column>
        </e-grid-columns>
    </ejs-grid>

I am changing the IdTipoLicencia  which is a foreing key column, as for example: (I need to do it with setCellValue)
gridInstance.setCellValue(selectedRows[1].Id, "IdTipoLicencia", 2);
But the change is not reflected in grid, I mean, the grid keeps showing the value that belongs to the previous Id, unless I do a change in the page for example.

I will appreciate any help.


1 Reply 1 reply marked as answer

RR Rajapandi Ravi Syncfusion Team June 3, 2021 10:21 AM UTC

Hi Juan, 

Greetings from syncfusion support 

Based on your query we could see that you like to change the cell value by using setCellValue method and like to get the changed value by using datasource and currentViewData of Grid. 

We would like to inform you that the setCellValue method is used for modifying the cell value only in the UI level and that is why it is not updated on performing the edit action. This is its default behavior. So, if you like to update the modified cell value to the Grid’s dataSource and currentViewData, we suggest you use the updateRow method to update the data values which are explained below. 

updateRow: 

If you need to update the row data in the Grid’s datasource, then we suggest you use the updateRow method. In this method you need to pass the index value of the row to be updated(Which can be retrieved with primary key value using the getRowIndexByPrimaryKey method) along with the updated data. Please check the below API for more information 


Regards,
Rajapandi R


Marked as answer
Loader.
Up arrow icon