Current filter:
                                You should refresh the page.
                                  • Hi,

                                    I am doing a Mobile App project.  In this project, I have used Dxdatagrid.  It allows to shows and insert data to same table.  But I want to show data from one table and I want to insert data to another table.  Please give examples to do this task.
                                Show all comments
                                • Nikolai (DevExpress Support) 08.11.2015
                                  Hi,

                                  Your task is not clear. Would you please clarify what you mean by "insert data to another table"? Describe your idea in greater detail. We will do our best to assist you.
                                • VQS DEVELOPER 08.11.2015

                                  Yes.  I want to insert data to another table.

                                • Nikolai (DevExpress Support) 08.12.2015

                                  To provide you with a precise answer, we need to get a better grasp of the issue. It is unclear what you mean by "insert data to another table". Would you please describe your scenario in greater detail? 

                                • VQS DEVELOPER 08.12.2015

                                  Hi,

                                  We are having two tables one is for Employee another is for Employee salary, For this we are binding the employee list in the grid, i.e the grid having the following details(I have bind the Employee table in the grid and added other columns statically,

                                  Employee Name (get from the employee table),
                                  No.of days working,
                                  Salary

                                  Here now I want to store the final grid result into the new table as Employee Salary. Also I want to add/update the records when cell change event as well.

                                • Nikolai (DevExpress Support) 08.12.2015
                                  Do you use OData service?
                                • VQS DEVELOPER 08.12.2015

                                  Yes.

                                1 Solution

                                Creation Date Importance Sort by

                                Thank you for your clarification. dxDataGrid does not allow modifying navigation properties. A possible solution is to send synchronous call to your data service to modify the "EmployeeSalary" data table in the dxDataGrid.onRowInserting event handler. The same approach can be used for updating an existing row. The following code snippet demonstrates how to update the "CategoryName" data field in the "Category" data table that is associated with the "Product" table:

                                [JavaScript]
                                var categories = new DevExpress.data.ODataStore({ url: 'http://YourDomain/DataService.svc/Categories', key: 'CategoryID', keyType: 'Int32' }); $("#container").dxDataGrid({ height: 400, dataSource: { store: { type: 'odata', url: 'http://YourDomain/DataService.svc/Products', key: 'ProductID', keyType: 'Int32' }, select: ['ProductID', 'ProductName', 'Category.CategoryName', 'CategoryID'], expand: 'Category' }, editing: { editEnabled: true, insertEnabled: true, removeEnabled: true }, columns: ['ProductID', 'ProductName', 'Category.CategoryName', {dataField: 'CategoryID', visible: false}], onRowUpdating: function (e) { if (e.newData.Category) { $.ajaxSetup({ beforeSend: function (jqXHR, settings) { settings.async = false; } }); categories.update(e.oldData.CategoryID, e.newData.Category); $.ajaxSetup({ beforeSend: null }); delete e.newData.Category; } }, onRowInserting: function (e) { if (e.data.Category) { $.ajaxSetup({ beforeSend: function (jqXHR, settings) { settings.async = false; } }); categories.load({ filter: ['CategoryName', '=', e.data.Category.CategoryName] }).done(function (data) { var categoryID = null; if (data.length) categoryID = data[0].CategoryID; if (!categoryID) { categories.insert(e.data.Category).done(function () { categories.load({ filter: ['CategoryName', '=', e.data.Category.CategoryName] }).done(function (result) { categoryID = result[0].CategoryID; }); }); } e.data.CategoryID = categoryID; }); $.ajaxSetup({ beforeSend: null }); delete e.data.Category; } } });

                                You can test this code snippet with OData service based on the Northwind data base.

                                See also:
                                dxDataGrid.onRowUpdating
                                ODataStore
                                ODataStore.insert
                                ODataStore.update
                                ajaxSetup

                                Show all comments
                                • VQS DEVELOPER 08.14.2015

                                  Thanks Nikolai.  In this scenario, you used foreign key references.  But I don't have foreign key in my project.   And also I want store one table data field to another table.(Ex: In your scenario, I want to store product name in category table(field name:category name))

                                • Nikolai (DevExpress Support) 08.17.2015

                                  Attached are a DevExtreme app that demonstrates the approach from my previous answer in action, a data service and database. Please describe how we can reproduce the issue with them. It would be great if you modify the project to show the issue and send it to us. We will examine it and put you on the right track.

                                • VQS DEVELOPER 08.17.2015

                                  What is the version sql server you used for this db?

                                • Nikolai (DevExpress Support) 08.17.2015
                                  It is MS SQL Server 2014. The Northwind database is a standard database and you can download it from here.
                                • VQS DEVELOPER 08.17.2015

                                  I have modified the project and reproduced the issue.  Please examine the project and give correct solution to this issue.

                                • Alex Skorkin (DevExpress Support) 08.18.2015

                                  Thank you for providing the modified project. Please give us additional time to examine it and setup a test environment.

                                • Alex Skorkin (DevExpress Support) 08.19.2015

                                  Hello, 

                                  Running your application I see the following error message: 

                                  Type 'NorthwindModel.Customer' does not have a property named 'Suppliers'; there is no service action named 'Suppliers' that is bindable to the type 'NorthwindModel.Customer'; and there is no type with the name 'Suppliers'.

                                  Is this the same message you were talking about?

                                • VQS DEVELOPER 08.19.2015

                                  yes

                                • Alex Skorkin (DevExpress Support) 08.19.2015

                                  Thank you for the clarification. 

                                  The error message states that 'Customers' and 'Suppliers' are not linked in the data base although you linked them in the data grid settings. 'Products' and 'Suppliers' are linked not through 'Suppliers' and 'Suppliers.HomePage', but through 'Supplier' and 'Supplier.HomePage'. 

                                  I recommend that you review the table structure through the 'DataService.svc/$metadata' request and perform the necessary changes.