<pre><code>
var view = new Roo.JsonView({
container: "my-element",
- template: '<div id="{id}">{foo} - {bar}</div>', // auto create template
+ tpl: '<div id="{id}">{foo} - {bar}</div>', // auto create template
multiSelect: true,
jsonRoot: "data"
});
});
</code></pre>
*
+* Note: old code is supported with arguments : (container, template, config)
*
*
* @constructor
* @param {Object} config The config object
*
*/
-Roo.JsonView = function(container, tpl, config){
+Roo.JsonView = function(config, depreciated_tpl, depreciated_config){
- Roo.JsonView.superclass.constructor.call(this, container, tpl, config);
+ Roo.JsonView.superclass.constructor.call(this, config, depreciated_tpl, depreciated_config);
var um = this.el.getUpdateManager();
um.setRenderer(this);
};
Roo.extend(Roo.JsonView, Roo.View, {
/**
- * The root property in the loaded JSON object that contains the data
- * @type {String}
+ * @type {String} The root property in the loaded JSON object that contains the data
*/
jsonRoot : "",
um.update.apply(um, arguments);
},
+ // note - render is a standard framework call...
+ // using it for the response is really flaky... - it's called by UpdateManager normally, except when called by the XComponent/addXtype.
render : function(el, response){
+
this.clearSelections();
this.el.update("");
var o;
try{
- o = Roo.util.JSON.decode(response.responseText);
- if(this.jsonRoot){
-
- o = /** eval:var:o */ eval("o." + this.jsonRoot);
+ if (response != '') {
+ o = Roo.util.JSON.decode(response.responseText);
+ if(this.jsonRoot){
+
+ o = o[this.jsonRoot];
+ }
}
} catch(e){
}