Question

I am working on an old code base which uses dojo datagrid and JsonRestStore, using declarative approach(in HTML). I am now trying to adapt this to use the newer dojo.store.JsonRest .

When I declare the JsonRest and ObjectStore in HTML, it works.

I want to use json.store.Cache as my store, with dojo.store.JsonRest and dojo.store.Memory backing it. The constructor for json.store.Cache takes two arguments.

a) Is there a possibility to define constructor arguments in HTML declarative style?

I didn't want to touch the (declarative) code of the Datagrid so I tried setting the store of the Grid in dojo.addOnLoad . I get a weird error in Firebug for dojo.js line 402 which is actually a comment:

// 5. Evaluated: the module was defined via define and the loader has evaluated the factory and computed a result.

My guess is that the error has nothing to do with dojo.js at all and the exception actually occurred in a closure somewhere(I think I've seen this before).

b) Is it possible to mix and match Declarative and Programmatic style in this way? And if yes, what event should I be setting the grid's store on?

Was it helpful?

Solution

I'm answering this myself as I figured it out later. There seems to be no problem in mixing and matching the declarative and programmatic style.

I changed from using dojo.addOnLoad to dojo.ready , but I don't think that was the problem anyway.

I was trying to set the datagrid's query in a call to datagrid.setQuery and then setting the store with datagrid.setStore. It didn't work no matter which order I tried in(query first or store first). Turns out both have to be set together in the call to setStore. The method accepts the query as its second parameter. This solved my problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top