使用 Flex 数据管理和 PHP 时出现问题
我正在使用 Flash Builder 4.5 for PHP 中的薪资管理系统。我正在使用 Flex 数据管理系统。我有一些问题,如下所述:
- 当我将项目添加到数据网格但不提交时,我无法删除它。这是可以理解的,因为删除仅当该项目位于数据库中时才有效,并且在将其提交到数据库之前我无法获取该项目的 id(主键)。
当我删除项目时,应该将其从数据网格中删除(这可以通过从数据网格的数据提供程序中删除项目来实现),但问题是当我提交它时 - 它保存到数据库中。我无法找到解决这个问题的方法。
有哪些关于 Flex 4 的好书/教程,重点关注 PHP 和 Flex 企业应用程序开发并通过示例解释应用程序开发?
I am working with a salary managment system in Flash Builder 4.5 for PHP. I am using a Flex data management system. I have a few issues which are addressed below:
- When I add an item to data grid and do not commit it, I am not able to delete it. This is understood because delete works only if the item is in the database and I don't get the id (primary key) for the item until I commit it to the database.
When I delete item it should be removed from the data grid (which can be achieved by removing items from the datagrid's data provider), but the issue is when I commit it - it saves to database. I am not able to find any solution to this problem.
What is some good book / tutorial for Flex 4 that focuses on PHP and Flex enterprise application development and explains application development with examples?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我在这种情况下所做的事情。对于我的 dataProvider 中尚未保存的已删除的行(它们的 ID=0 或其他内容),我只需使用以下内容删除它们:
这样,任何已删除的行将永远不会到达后端。
Here's what I've done in this situation. For rows in my dataProvider that have not been saved yet (they have ID=0 or something) that are deleted, I just remove them using something like:
This way any rows that were deleted will never make it to the back end.
我没有使用数据网格(或 ArrayCollection 作为数据提供者),因此虽然 @Jason Towne 的解决方案一般有效,但它不是针对我的具体情况的解决方案。
我通过使用 Flex 中的数据管理 DELETE 方法的 item 而不是 itemID 解决了“无法删除未提交的项目”问题。 Flash Builder 自动生成的 ActionScript 方法和 PHP 代码使用 itemID 作为参数,该参数在将记录保存到数据库之后才适用于数据管理的 DELETE。在 DELETE 方法中使用实际的 item 引用作为参数可以删除已提交和未提交的更改。然后必须修改 PHP 代码。
我使用服务器端输入,因此修改后的 PHP 代码(与 FB 自动生成的 PHP 代码非常相似)如下所示:
Flex 代码:
I'm not using a datagrid (or ArrayCollection as dataProvider) so although @Jason Towne 's solution works in general, it wasn't a solution for my specific case.
I resolved the 'not being able to delete uncommitted items' problem by using item rather than itemID for the data managed DELETE method in Flex. Flash Builder's auto generated ActionScript method and PHP code uses itemID as parameter which doesn't work on data managed DELETE till AFTER a record is saved to database. Using the actual item reference as param in DELETE method works to delete committed AND uncommitted changes. PHP code will then have to be modified.
I use server side typing, so the modified PHP code (which closely resembles FB auto generated PHP code) looks like:
The Flex code then: