Question

I'm trying to use a enhanced grid with Dojo JSONREST and i'm running into some issues. I've been looking up some examples but can't figure out how to do what i need.

In the code below my rest service takes two parameters, and the query on the service works. The problem is that when grid.startup() is called it seems to call the Rest service again, since there are no parameters passed the rest service falls over. What am i doing wrong here?

Also is there any way to update to the store so that is only contains the queried results?, so that when the grid appears it just contains these values?

Appreciate any help or pointers..

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();
}

No correct solution

OTHER TIPS

Have you tried setting the query parameter of the grid? A link to the docs. And a link to an example.

And by looking at the code in the question, it seems that the grid should display chunks/pages of data - an example using the pagination plugin for the grid.

The filter plugin might also be of interest to you.

when you define a new grid you have to pass it to 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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top