【问题标题】:Dojo Enhanced Grid with JSONREST issues带有 JSONREST 问题的 Dojo 增强网格
【发布时间】:2013-12-03 09:11:32
【问题描述】:

我正在尝试将增强的网格与 Dojo JSONREST 一起使用,但遇到了一些问题。 我一直在查找一些示例,但无法弄清楚如何做我需要的。

在下面的代码中,我的 rest 服务接受两个参数,并且对服务的查询有效。 问题是,当调用 grid.startup() 时,它似乎再次调用了 Rest 服务,因为没有传递任何参数,rest 服务就会失败。我在这里做错了什么?

还有什么方法可以更新到商店,只包含查询的结果?这样当网格出现时它只包含这些值?

感谢任何帮助或指示..

ready(function(){

  var grid;

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

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

      // how do i update store with queried results?

      });

  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
  }, document.createElement('div'));

grid.startup();
}

【问题讨论】:

    标签: dojo dojox.grid.datagrid dojox.grid


    【解决方案1】:

    当您定义一个新网格时,您必须将其传递给 dojo:

    /*create a new grid:*/
      grid = new EnhancedGrid({
      id: 'grid',
      store: dataStore,
      structure: layout,
      selectable: true,
      selector: false,
      selectionMode: 'none',
      escapeHTMLInData: false,
      autoHeight:true
     }, document.createElement('div'));
    
     /*append the new grid to the div*/
     dojo.byId("gridDiv").appendChild(grid.domNode);
    
     grid.startup();
    

    【讨论】:

      【解决方案2】:

      你试过设置网格的查询参数吗? A link to the docsAnd a link to an example.

      通过查看问题中的代码,网格似乎应该显示数据块/页面 - an example using the pagination plugin for the grid

      The filter plugin 您可能也会感兴趣。

      【讨论】:

      • 您好,谢谢您,setQuery 有效。我现在无法刷新网格....如果我将不同的查询参数传递给网格似乎没有更新的方法。你有如何刷新网格的例子吗?
      • 网格有一个update 方法。请参阅API docs
      • 所以如果我想刷新网格,我用新参数调用另一个集合查询,然后调用更新?
      • 只需 setQueryupdate 应该可以工作。不过,从未尝试过使用 REST 存储。
      猜你喜欢
      • 2013-11-01
      • 2011-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多