0

我是一个绝对的新手,一直在用 ExtJS 工作和挣扎!我应该得到一个用户记录列表并将它们显示在 Ext 网格面板上。我有一个 ExtJS 前端和 Grails(Groovy 控制器)后端。我提到了一些链接,例如:

http://docs.sencha.com/extjs/4.0.7/#!/example/grid/row-editing.html
http://docs.sencha.com/extjs/4.0.7/#!/example/restful/restful.html
http://docs.sencha.com/extjs/4.0.7/#!/example/writer/writer.html

The api property ( or ) tag ( or )attribute ( I don't know what it is called ) helps me in getting the list of JSON objects to be displayed in the Grid. Also, when I select a row and click on Delete, the request is reaching the delete action in my controller. But my problems begins here: how do I make sure that:

1) the selected row is deleted from Database? How do I pass the identifier or something to controller so that it will delete the record?

2) When I add a row, how do I pass the field values to backend Controller?

Most of the code is same as given in the restful link above. For reference, this is my Datastore:

https://docs.google.com/document/d/1gQyLCt6xWXTm-OUgYu7hku47r5WcS0my5yPBSKj2B7I/edit?usp=sharing
4

1 回答 1

0

如果您使用 Rest 代理,ExtJS 将根据您指定的 url 存根为您自动生成 url。因此,如果您的代理配置为指向以下内容:/api/users,则将为 4 个操作中的每一个生成以下 url:

  • 阅读:/api/users (GET)
  • 创建:/api/users (POST)
  • 更新:/api/users/SomeIDFromTheUpdatedRecord (PUT)
  • 删除:/api/users/SomeIDFromTheDeletedRecord(删除)

如您所见,每个请求的端点完全相同(api/users),但对于 PUT 和 DELETE,受影响记录的 id 会自动包含在 URL 中。

当然,对于 POST 和 PUT 请求,您可以添加任何您想发送到服务器的附加参数,尽管当您通过商店配置的代理保存模型实例时,这将自动完成。

于 2013-05-23T02:37:41.297 回答