PDA

View Full Version : [CLOSED] [4.2.1 beta] TreePanel's fields ignore mapping



Daniil
6 May 2013, 3:16 AM
REQUIRED INFORMATION

Ext version tested:

Ext 4.2.1 beta

Browser versions tested against:

Chrome
IE9

DOCTYPE tested against:

<!DOCTYPE html>

Description:

A TreePanel's fields ignore mapping.

Steps to reproduce the problem:

Click the Buttom

The result that was expected:

"Hello!" in the alert box

The result that occurs instead:

Nothing in the alert box

Test Case:


<!DOCTYPE html>
<html>
<head>
<title>TreePanel's fields ignore mapping</title>

<link rel="stylesheet" href="../resources/css/ext-all.css" />

<script src="../ext-all-debug.js"></script>

<script>
Ext.onReady(function () {
var tree = Ext.create("Ext.tree.Panel", {
renderTo: Ext.getBody(),
fields: [{
name: "text"
}, {
name: "someFieldName",
mapping: "test"
}],
root: {
leaf: true,
text: "Root",
test: "Hello!"
}
});
Ext.create("Ext.button.Button", {
renderTo: Ext.getBody(),
handler: function () {
alert(tree.getRootNode().data.someFieldName);
},
text: "Get"
});
});
</script>
</head>
<body>
</body>
</html>

evant
6 May 2013, 5:03 AM
Typically fields are only run through the reader if it's loaded remotely. You'd see the same behaviour with a grid. A mapping is only really required if you're reading it directly from the server. If you're able to do it locally, it means you've got control of the format.

Daniil
6 May 2013, 8:38 PM
Thank you for the answer, Evan.

It looks a real scenario to load some nodes from a server bypasing a TreeStore and add those nodes by, for example, an appendChild call, and expect that mapping will be taken into account.

Also it looks inconsistent that a convert function executes in such a scenario, but mapping is not.

It would be also nice to see a pair of words about it here.
http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.data.Field-cfg-mapping

What do you think?