简体   繁体   中英

ASP.NET Core - Add rows from one dev express grid to another

I have an ASP.NET Core project. (Razor pages), in this application. I have two devexpress grids:

在此处输入图片说明

The goal here is to click on a row, and then click the floating action button (the add) and then it will add the selected row to the grid on the right.

I've got a javascript function which passes the sales order to the code behind method:

在此处输入图片说明

My code behind: (Controller)

在此处输入图片说明

EDIT:

I am not able to find my devexpress grid in the code behind class. I assume these devexpress grids refresh themselves as I cannot find a way to refresh them via code. In my mind it should be something like this.devExpressGrid.Refresh();

Oh and here's that EmptySalesOrder model:

在此处输入图片说明

Since this is a client side only control there is no way to get the reference in the code behind.

I do not know what you business logic is but I think there might be two scenarios here.

  • You select the row and press button to add it to the right grid. The 'Add' action posts some data to the server and there is some kind of update on the database. The only thing now that remains is to update the right grid. Do so by refreshing it or its data source. For this to work the right grid should have it's own data source that goes on server and fetches the added sales orders.
  • You select the row and press button to add it to the right grid. The 'Add' action updates the data source of the right grid without going to the server.

I don't know which one of these is your scenario but in any case you should read up a bit on the custom data source that you can plug in the grid. This is in my opinion easiest solution for you since you would be operating on the data source itself so you wouldn't be worrying about the grid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM