DataGrid - 单击按钮时编辑选定的行

发布于 2024-08-17 14:06:02 字数 573 浏览 5 评论 0原文

我有一个非常简单的包含 2 列的 DataGrid,如下所示:

<mx:DataGrid id="grid" >
    <mx:columns>
        <mx:DataGridColumn dataField="name" headerText="Name"/>
        <mx:DataGridColumn dataField="date" headerText="Date"/>
    </mx:columns>
</mx:DataGrid>

我想做的是当用户单击按钮时激活所选行的版本。到目前为止,我还找不到任何如何执行此操作的示例。我已经尝试了 6 或 7 种不同的方法,但没有效果。有谁知道如何做到这一点?

如何获取 DataGrid 的选定行(不是 selectedItem)以及如何:

  • 即时更改该行的 ItemRenderEditor 或 ItemRenderer。
  • 或者启用该特定行的版本而不单击它。

这是我一直无法回答的问题,

我们将不胜感激。

I have a very simple DataGrid with 2 columns, some thing like this:

<mx:DataGrid id="grid" >
    <mx:columns>
        <mx:DataGridColumn dataField="name" headerText="Name"/>
        <mx:DataGridColumn dataField="date" headerText="Date"/>
    </mx:columns>
</mx:DataGrid>

What Im trying to do is to activate the edition of the selected row when the user clicks a button. So far I've been unable to find any example of how to do this. I already tried 6 or 7 different approaches but non works. Does any one has a clue how to do this?

How do you get the selected row (NOT selectedItem) of a DataGrid and how can you:

  • Change the ItemRenderEditor or ItemRenderer on the fly of just that row.
  • Or enable the edition of that specific row without clicking it.

This are the questions that I've been unable to answer

Help will be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心旳酸楚 2024-08-24 14:06:02

您可以使用 grid.selectedIndex 属性获取选定的行。对您问题的一个想法:

  • 向数据网格中的项目添加一个“可编辑”属性,默认情况下为 false
  • 单击按钮时,设置 grid.selectedItem.editable = true;
  • 将网格的项目渲染器更改为新的项目渲染器,如果项目可编辑,则显示 TextInput 字段;如果不可编辑,则仅显示普通标签。

您可以在运行时更改项目渲染器,如下所示:

grid.itemRenderer = new ClassFactory(com.myapp.renderers.MyGridItemRenderer);

You can get the selected row with the grid.selectedIndex property. One thought to you problem:

  • Add an "editable" property to you items in the datagrid which is false by default
  • When clicking on the button, set grid.selectedItem.editable = true;
  • Change the grid's item renderer to a new one, which displays TextInput fields if an item is editable or just plain Label if it's not

You can change the item renderer at runtime like this:

grid.itemRenderer = new ClassFactory(com.myapp.renderers.MyGridItemRenderer);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文