extnet / examples5.ext.net

Apache License 2.0
18 stars 17 forks source link

Several examples' data not showing #31

Closed fabriciomurta closed 1 year ago

fabriciomurta commented 1 year ago

Several examples with Ajax proxy-based data are not displaying the associated data.

This is because Ext JS changed its default JSON handing to use browser's internal interpreter. Several examples had JSON files compatible with ExtJS's internal interpreter, and in turn, weren't really JSON compliant, but valid JavaScript Objects.

This issue was introduced with extnet/Ext.NET#1605, when Ext.NET no longer forced the default to previous Ext JS default over a major version upgrade.

In order for the examples to work, their current syntax:

[{
    id: 1,
    name: 'Customer A',
    phone: '540-111-1234'
}, {
    id: 2,
    name: 'Customer B',
    phone: '650-222-2345'
}, {
    id: 3,
    name: 'Customer C',
    phone: '412-333-3456'
}, {
    id: 4,
    name: 'Customer D',
    phone: '861-444-4567'
}]

Should be rewritten with json-conforming syntax:

[{
    "id": 1,
    "name": "Customer A",
    "phone": "540-111-1234"
}, {
    "id": 2,
    "name": "Customer B",
    "phone": "650-222-2345"
}, {
    "id": 3,
    "name": "Customer C",
    "phone": "412-333-3456"
}, {
    "id": 4,
    "name": "Customer D",
    "phone": "861-444-4567"
}]
fabriciomurta commented 1 year ago

This replacement command should fix most cases in the repository (notably, not the Data Binding > Chained Combos example):

for file in $(find ./ -iname '*.json'); do
  if egrep -q "[a-zA-Z0-9_]+:" "${file}"; then
    echo "${file}"
    sed -Ei "s/ ([a-zA-Z_][a-zA-Z0-9_]*):/ \"\1\":/g;s/'(.*)'(,)?$/\"\1\"\2/g" "${file}"
  fi
done
fabriciomurta commented 1 year ago

Fixed via 257766a and updated in live site.