编辑Datagrid的记录 [英] Edit record of Datagrid

查看:52
本文介绍了编辑Datagrid的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在此线程

我想看一个例子:

1. Datagrid的每一行都有一个编辑"按钮
2.单击编辑"按钮后,保存并保存.取消按钮将可用
3.保存按钮将保存更改的记录
4.取消按钮会将记录恢复为原始值
5.如果未单击保存"或取消"按钮,则我们将无法跳转".到其他记录.


非常感谢&最好的问候,华敏

Hi,
Further to this thread

I want to see an example:

1. Each row of Datagrid, is having one Edit button
2. When Edit button is clicked, Save & Cancel buttons would be available
3. Save button would save the record changed
4. Cancel button would restore the record to its original values
5. If either Save or Cancel buttons are not clicked, we cannot "jump" to other record.


Many Thanks & Best Regards, Hua Min

推荐答案

为什么要有一个编辑"按钮?

Why would you have an Edit button at all?

数据网格的工作方式是单击一行,然后进入编辑模式.

The way the datagrid works is you click a row and it goes into edit mode.

您不需要按钮即可完成操作.

You don't need a button to do that.

我认为您正在尝试以不希望使用的方式使用数据网格.

I think you're trying to use a datagrid in a way it's not intended to be used.

正如我在该线程上所解释的.

As I explained on that thread.

一旦用户想离开行,就很难停止它.

It's very difficult to stop the user once they want to leave a row.

它将离开将提交更改的行.

It is leaving the row which will commit changes.

您可以编写许多代码并尝试捕获所有极端情况.

You can write a lot of code and try and trap all the edge cases.

但是,基本上,如果您希望能够使用保存并取消"按钮,则不要在datagrid行中进行编辑.

But, basically, if you want to be able to use a save and cancel button then do not edit in the datagrid row.

在数据网格顶部或侧面使用面板.然后,您可以控制用户何时执行操作.您可以在对象单击编辑时对其进行克隆.他们在那个克隆上工作.如果他们按了取消,那么您只需将对象装箱.如果他们点击提交 您会以某种方式将其复制到原始文件中,具体取决于您连接数据的方式.

Use a panel on top of the datagrid or to the side of it. Then you can have control over when the user does what. You can clone an object when they click edit. They work on that clone. If they hit cancel then you just bin the object. If they hit commit then you copy it over the original somehow, depending on how you're connecting to your data.


这篇关于编辑Datagrid的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆