javascript - 在 ExtJS 3.0 中通过来自 EditorGridPanel 的 XmlHttpRequest 自动保存?

标签 javascript gridview extjs

我在 Ext JS 3.0 中有一个 EditorGridPanel,通过 HttpProxy 和 JsonReader 填充,并且我有一个可编辑的“工作”列——我可以编辑该值并将其标记为脏。

现在,我如何才能在编辑单元格后向服务器发送 XmlHttpRequest,其中包含一些基本参数、行的 ID 字段、已更改的列的名称以及新值?

一旦发出请求,服务器端更新就很容易了。但是,无论使用多少 Google 和深入挖掘简单的内存中 EditGridPanel 示例,都无法帮助让 EditGridPanel 进行调用。

我不寻找的是:

  1. REST——只需通过普通的 GET 或 POST 更新
  2. 插入新记录或删除行——目前仅更新。
  3. 批量更新——一次只修改一个单元格。
  4. 一堆代码——这应该是微不足道的,比如 Scriptaculous 中的 Ajax.InPlaceEditor

最佳答案

我终于想通了......我的店里只需要一个作家:

var ds = new Ext.data.JsonStore({
    autoSave:       true,
    url:            "ajax-handler.aspx",
    method:         "POST",
    timeout:        120000,
    root:           "rows",
    totalProperty:  "results",
    idProperty:     "primarykeyvalue",
    fields:         previewColumnConfig,
    baseParams:     {
        now:        (new Date()).getTime()
        },
    writer: new Ext.data.JsonWriter({
        encode:     true,
        listful:    false
        })
    });

注意事项:

  • “现在”的基本参数是为了绕过“某些浏览器”(猜一猜)AJAX 结果的缓存
  • “encode”返回 POST 变量,而不仅仅是 POST 中的纯 JSON 结果。
  • “listful”被禁用,因为用户一次只编辑一行/一列,无需设计服务器端解析器来引入数组,它只需要一行。
  • 是的,我有一个很长的超时值。
  • previewColumnConfig 是预先定义的,存储我的列定义。

关于javascript - 在 ExtJS 3.0 中通过来自 EditorGridPanel 的 XmlHttpRequest 自动保存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1202918/

相关文章:

javascript - DurandalJs : A generic solution to put focus to the first input element on the composed view

android - 为什么只有第一行显示使用 Recyclerview gridlayoutmanager

c# - 防止空 Gridview 数据将 " "填充到文本框中

asp.net - 当我设置宽度时,为什么 GridView 宽度没有在整个页面上扩展 100%?

html - sencha 或 Extjs 怎么样?

javascript - 在集会 : Can I map custom task states to existing Task states in a Rally Task Board (similar to Kanban for user stories)?

mobile - 用户或个人资料选项卡图标不可见

javascript - 测试 DOM 中元素的最佳方法是什么

javascript - 如何在 v-if 条件下使用 Vue.js 变量/参数

javascript - 当我使用 bootstrap 4 时,为什么粘性 header 在表单标签中不起作用?