Mewriick / Blazor.FlexGrid

GridView component for Blazor
MIT License
198 stars 36 forks source link

Error on update - replace unchanged value by last value modified #89

Closed Methraen closed 4 years ago

Methraen commented 4 years ago

@Mewriick 1 - When i save a new value on a row, 2 - And then, i save another row without changing any value this time, 3 - The value that was changed in the first case replaced the unchanged value of the second one

Methraen commented 4 years ago
...
      ForecastOld = await Http.GetJsonAsync<TestDto[]>("sample-data/test.json");
      ForecastNew = await Http.GetJsonAsync<TestDto[]>("sample-data/test.json");
      dataAdapter = new CollectionTableDataAdapter<TestDto>(ForecastNew);
...

public void ItemSavedOperationFinished(SaveResultArgs saveResultArgs)
    {
      bool res = false;
      TestDto ItemSaved = (TestDto)saveResultArgs.Item;
      TestDto newObj = ItemSaved.CopyPaste();//newObj get the values of ItemSaved without being on the same memory space
      for (int i = 0; i < ForecastOld.Length; i++)
      {
        if (newObj.Code == ForecastOld[i].Code)
        {
          if (!newObj.IsEqual(ForecastOld[i]))
          {
            res = true;
            ForecastOld[i] = newObj;
            UpDate[newObj.Code] = DateTime.Now;
          }
          break;
        }
      }

      if (res == true)
      {
        Console.WriteLine($"Item saved result: {saveResultArgs.ItemSucessfullySaved}");
        Console.WriteLine(saveResultArgs.Item.ToString());
      }
      else Console.WriteLine("The item was not modified");
    }
Methraen commented 4 years ago

pb

Mewriick commented 4 years ago

@Methraen

New verison is released and this issue should be sovled