PDA

View Full Version : Getting Runtime Error



navipnr
13 Sep 2010, 1:56 AM
Hi,

I am getting an runtime error when i executing this page. Please help me to solve this
I am attaching the code

................

<html>
<head>
<title> Data View Test 2 </title>
<!-- ExtJS library: base/adapter -->
<script type="text/javascript" src="../../adapter/ext/ext-base-debug.js"></script>
<!-- ExtJS library: all widgets -->
<script type="text/javascript" src="../../ext-all-debug.js"></script>

<script type="text/javascript">
Ext.onReady(function() {
var arrayData = [
['Jay Garcia', 'MD'],
['Aaron Baker', 'VA'],
['Susan Smith', 'DC'],
['Mary Stein', 'DE'],
['Bryan Shanley','NJ'],
['Nyri Selgado', 'CA']
];

var nameRecord = Ext.data.Record.create([
{ name : 'name', mapping : 0 },
{ name : 'state', mapping : 1 }
]);

var arrayReader = new Ext.data.ArrayReader({}, nameRecord);

var memoryProxy = new Ext.data.MemoryProxy(arrayData);

var store = new Ext.data.Store({
reader : arrayReader,
proxy : memoryProxy
});

store.load();

var dataview = new Ext.DataView({
store: store,
tpl : new Ext.XTemplate(
'<ul>',
'<tpl for=".">',
'<li >',

'<strong>{name}</strong>',

'</li>',
'</tpl>',
'</ul>'
),
singleSelect: true,
multiSelect : true,
autoScroll : true
});

dataview.render(document.body);

});
</script>


</head>

<body >
This is an example of data view

</body>
</html>

Condor
13 Sep 2010, 2:08 AM
1. You are using an ArrayReader, so you don't need to specify the mappings (those are default).
2. Why are you using a MemoryProxy? You should just specify data:arrayData in the store (and remove proxy and the load call).
3. A DataView should be singleSelect:true or multiSelect:true, but not both.
4. Any more information? What kind of runtime error?

navipnr
13 Sep 2010, 2:32 AM
I'm getting the same error by making above changes

Getting an error
......................
Line : 1078
Error : 'undefined' is null or not an object.
......................

When debug with visual studio 2010, I can see path variable is null

Help me...

Condor
13 Sep 2010, 2:43 AM
A linenumber if meaningless without some context.
- Which Ext version are you using?
- Which Ext file is this error in (ext-all-debug.js?).

navipnr
13 Sep 2010, 2:52 AM
Version : ext-3.2.1
in ext-all-debug.js

inside the function

jsSelect: function(path, root, type){

root = root || document;

if(typeof root == "string"){
root = document.getElementById(root);
}
var paths = path.split(","),
results = [];


for(var i = 0, len = paths.length; i < len; i++){
var subPath = paths[i].replace(trimRe, "");

if(!cache[subPath]){
cache[subPath] = Ext.DomQuery.compile(subPath);
if(!cache[subPath]){
throw subPath + " is not a valid selector";
}
}
var result = cache[subPath](root);
if(result && result != document){
results = results.concat(result);
}
}

.
.
.
.

Here the value of path is getting null


Thanks,
Navaneeth

Animal
13 Sep 2010, 3:17 AM
DataView needs an itemSelector.

This is in the API docs, flagged as mandatory