如何使用新数据更新增强型网格 [英] How to update enhanced grid with new data

查看:192
本文介绍了如何使用新数据更新增强型网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个enhnaced网格连接到JSONRest,我有一个填充网格启动后。
对于在执行新查询时如何更新网格存储,我感到困惑,任何人都可以帮助?

I have an enhnaced grid connected to a JSONRest and i have it populating after the grid starts up. I'm confused as to how to update the Grid store when a new query is performed, can anyone help ?

    var store = new JsonRest({
        target: "rest/search"
    }); 

    dataStore = new ObjectStore({ objectStore: store });

            /*set up layout*/
    var layout = [[
       {'name': 'Name', 'field': 'col1', noresize: true, 'width': '100%'},
    ]];

    /*create a new grid:*/
    grid = new EnhancedGrid({
        id: 'grid',
        store: dataStore,
        structure: layout,
        selectable: true,
        selector: false,
        selectionMode: 'none',
        escapeHTMLInData: false,
        autoHeight:true,


        plugins: {
          pagination: {
            pageSizes: ["10", "25", "50"],
            description: true,
            pageStepper: true,
            maxPageStep: 4,  
            defaultPageSize: 5,
            sizeSwitch: true,
            position: 'bottom'
          }
        }
      }, document.createElement('div'));


    grid.setQuery({
        term: "term",
        category: "category"
      });

    grid.startup();

做一个store.query做我的后端,但是如何用结果重新填充网格?

Doing a store.query does hit my back end, but how do i repopulate the Grid with the results?

    store.query({term: "newterm", category: "newcategory"},
              {
                start: 10,
                count: 10,
              }).then(function(data){





              });


推荐答案

为了填充网格,你不应该直接执行商店查询 - 您应该指示网格使用商店,并且会自动查询。

In order to populate the grid, you shouldn't be performing a store query directly - you should be instructing the grid to use the store, and it will query it itself.

您已经看起来正在将商店实例分配您调用DataGrid构造函数,并且正确地使用 dojo / data / ObjectStore (因为dojox网格不支持 dojo / store ),所以我不清楚为什么甚至尝试执行一个查询。只要您调用 grid.startup()

You already appear to be assigning the store instance in your call to the DataGrid constructor, and you're properly wrapping it with dojo/data/ObjectStore (since dojox grid doesn't support dojo/store), so it's not clear to me why you are even attempting to perform a query beyond that. You should see a network request to your service as soon as you call grid.startup().

如果您在创建网格时看到网络请求,但是您没有看到网格中的结果,您的服务可能实际上并不遵循 dojo / store / JsonRest 期望。请参阅 http://dojotoolkit.org/reference-guide/1.9/quickstart/rest。 html ,以获取有关请求和响应中预期的内容的信息。

If you're seeing a network request being made when you create the grid but you're not seeing results in the grid, chances are your service does not actually follow the conventions that dojo/store/JsonRest expects. See http://dojotoolkit.org/reference-guide/1.9/quickstart/rest.html for information on what is expected in requests and responses.

如果您实际询问如何让网格在某些时候使用不同的商店在将来,调用 grid.setStore(newstore)

If you're actually asking how to tell the grid to use a different store at some point in the future, call grid.setStore(newstore).

这篇关于如何使用新数据更新增强型网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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