PDA

View Full Version : [CLOSED] MemoryProxy Error



softmachine2011
Jun 18, 2012, 2:59 PM
Hi,

I have a function in one of my plugins that pass the specified parameters to the following function



ToArrayStore: function (records, fields, pageSize, proxy) {
var storeNew = new Ext.data.ArrayStore({
fields: fields,
warningOnDirty: false,
proxy: proxy,
autoLoad: {
params: {
start: 0,
limit: pageSize
}
},
warningOnDirty: false,
sorters: [{
property: fields[1],
direction: 'ASC'
}]
});
storeNew.loadData(records);

return storeNew;
},


But it crashes in setProxy method internally in the constructor of ArrayStore.
The proxy that I pass is like



var proxy = new Ext.data.MemoryProxy(records);


And inside setProxy function proxy.type is undefined and when it try to resolve and instantiate the class crash.
But if I create the proxy like this, it works.



var proxy = new Ext.data.MemoryProxy(records);
proxy.type = 'memory';


Is it a bug?

Daniil
Jun 18, 2012, 4:06 PM
Hi,

I am unable to reproduce the problem using the code you have posted.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script type="text/javascript">
var ToArrayStore = function (records, fields, pageSize, proxy) {
var storeNew = new Ext.data.ArrayStore({
fields : fields,
warningOnDirty : false,
proxy : proxy,
autoLoad : {
params : {
start : 0,
limit : pageSize
}
},
sorters : [{
property : fields[1],
direction : 'ASC'
}]
});
storeNew.loadData(records);

return storeNew;
};

var onClick = function () {
var records = [{
test : "test1"
}, {
test : "test2"
}],
proxy = new Ext.data.MemoryProxy(records),
store = ToArrayStore(records, [{
name : "test"
}], 10, proxy);

console.log(store.getTotalCount());
};
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Button runat="server" Text="Click me">
<Listeners>
<Click Fn="onClick" />
</Listeners>
</ext:Button>
</body>
</html>


Also I don't think you need any proxy if you use the loadData method.

If you'd remove

proxy : proxy
in the example, it will function the same.

softmachine2011
Jun 19, 2012, 7:03 AM
I tried without proxy and it works too, thanks