diff --git a/ASP.NET Core/Controllers/DataGridEmployeesByStateController.cs b/ASP.NET Core/Controllers/DataGridEmployeesByStateController.cs index d28945d..91c56b2 100644 --- a/ASP.NET Core/Controllers/DataGridEmployeesByStateController.cs +++ b/ASP.NET Core/Controllers/DataGridEmployeesByStateController.cs @@ -8,7 +8,7 @@ using ASP_NET_Core.Models; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Newtonsoft.Json; +using System.Text.Json; namespace ASP_NET_Core.Controllers { @@ -24,9 +24,8 @@ public object Get(DataSourceLoadOptions loadOptions) [HttpPost] public IActionResult Post(string values) { - var newEmployee = new EmployeeByState(); - JsonConvert.PopulateObject(values, newEmployee); - + var newEmployee = JsonSerializer.Deserialize(values); + newEmployee.ID = SampleData.DataGridEmployeesByState.Max(a => a.ID) + 1; if (!TryValidateModel(newEmployee)) return BadRequest("Failed to insert item"); @@ -40,7 +39,7 @@ public IActionResult Put(int key, string values) { var employee = SampleData.DataGridEmployeesByState.First(a => a.ID == key); - PopulateModel(JsonConvert.DeserializeObject(values), employee); + PopulateModel(JsonSerializer.Deserialize(values), employee); if (!TryValidateModel(employee)) return BadRequest("Failed to update item"); diff --git a/README.md b/README.md index ab5412b..e78db8b 100644 --- a/README.md +++ b/README.md @@ -12,16 +12,22 @@ This example demonstrates how to implement cascading DropDownBoxes. The main ide ## Files to Review - **jQuery** - - [index.html](jQuery/index.html) + - [index.html](jQuery/src/index.html) + - [index.js](jQuery/src/index.js) - **Angular** - [app.component.html](Angular/src/app/app.component.html) - [app.component.ts](Angular/src/app/app.component.ts) - **Vue** - - [App.vue](Vue/src/App.vue) + - [Home.vue](Vue/src//components/HomeContent.vue) + - [StateDropDownBoxComponent](Vue/src/components/StateDropDownBoxComponent.vue) + - [CityDropDownBoxComponent](Vue/src/components/CityDropDownBoxComponent.vue) + - [DropDownSaveBtnComponent](Vue/src/components/DropDownSaveBtnComponent.vue) - **React** - - [App.js](React/src/App.js) + - [App.tsx](React/src/App.tsx) + - [DropDownBox.tsx](React/src/components/MultipleDropDownBox.tsx) + - [DropDownBoxSaveButton](React/src/components/DropDownBoxSave.tsx) - **ASP.Net** - - [Index.cshtml](ASP.NET/DevExtremeAspNetCoreApp1/Views/Home/Index.cshtml) + - [Index.cshtml](ASP.NET%20Core/Views/Home/Index.cshtml) ## Documentation diff --git a/React/src/App.tsx b/React/src/App.tsx index 199ac78..38bcc6d 100644 --- a/React/src/App.tsx +++ b/React/src/App.tsx @@ -4,7 +4,7 @@ import DataGrid, { } from 'devextreme-react/data-grid'; import './App.css'; import ArrayStore from 'devextreme/data/array_store'; -import { DataSource, type DataSourceOptions } from 'devextreme-react/common/data'; +import { type DataSourceOptions } from 'devextreme-react/common/data'; import service, { type City, type Employee } from './data'; import MultipleDropDownBox from './components/MultipleDropDownBox'; @@ -47,7 +47,7 @@ function renderMultipleDropDownBox( currentValue: number[], // eslint-disable-next-line no-unused-vars setValue: (value: number[]) => void, - dataSource: ArrayStore | DataSource, + dataSource: ArrayStore | DataSourceOptions, ): JSX.Element { return ( ): DataSource => { +const cityDataSource = ( + cellInfo: DxDataGridTypes.ColumnEditCellTemplateData +): DataSource => { return new DataSource({ store: new ArrayStore({ data: cities,