Hi,
I have been playing with smartclient and found that there are some problems when a RestDataSource has its dataFormat defined as "json". When this happens, the Databound component (tested with grid and tree) will not be able to reflect any newly added or updated records.
I have tested using the isomorphic example found in my own copy of smartclient at
http://localhost:8080/isomorphic/system/reference/SmartClient_Explorer.html#restEditSave and changed the 2 files country_fetch.xml and country_add.xml accordingly.
(in your smatclient website, you can refer to this copy. http://www.smartclient.com/isomorphic/system/reference/SmartClient_Explorer.html#restEditSave).
Whenever I add "dataFormat: "json" into the datasource definition and then replace the xml data with json format. Loading JSON formatted data works without any problems. However clicking on the add button does not refresh the list data with the new entry.
Below are the data I converted from xml to json. Please confirm if this is indeed a problem or have I generate the wrong json format?
Thanks in advance
---------Section modified in the example JS
isc.RestDataSource.create({
ID:"countryDS",
dataFormat:"json",
fields:[
{name:"countryCode", title:"Code", primaryKey:true, canEdit:"false"},
{name:"countryName", title:"Country"},
{name:"capital", title:"Capital"}
],
fetchDataURL:"/isomorphic/system/reference/inlineExamples/dataIntegration/xml/responses/country_fetch_rest.xml",
addDataURL :"/isomorphic/system/reference/inlineExamples/dataIntegration/xml/responses/country_add_rest.xml",
updateDataURL:"/isomorphic/system/reference/inlineExamples/dataIntegration/xml/responses/country_update_rest.xml",
removeDataURL:"/isomorphic/system/reference/inlineExamples/dataIntegration/xml/responses/country_remove_rest.xml"
});
-----------------------------------------
------country_fetch.xml
{
response: {
status: 0,
startRow: 0,
endRow: 7,
totalRows: 7,
data: [
{
continent: "North America",
countryName: "United States",
countryCode: "US",
area: 9631420,
gdp: 1830000,
population: 298444215,
independence: "1776-07-04",
government: "federal republic",
government_desc: 2,
capital: "Washington, DC",
members_g8: true,
article: "http://en.wikipedia.org/wiki/United_states"
},
{
continent: "Europe",
countryName: "Germany",
countryCode: "GM",
area: 357021,
gdp: 1830000,
population: 82422299,
independence: "1871-01-18",
government: "federal republic",
government_desc: 2,
capital: "Berlin",
members_g8: true,
article: "http://en.wikipedia.org/wiki/Germany"
},
{
continent: "Europe",
countryName: "United Kingdom",
countryCode: "UK",
area: 60609153,
population: 298444215,
gdp: 1830000,
independence: "1801-01-01",
government: "constitutional monarchy",
government_desc: 2,
capital: "London",
members_g8: true,
article: "http://en.wikipedia.org/wiki/United_kingdom"
},
{
continent: "Europe",
countryName: "France",
countryCode: "FR",
area: 547030,
population: 298444215,
gdp: 1816000,
government: "republic",
government_desc: 2,
capital: "Paris",
members_g8: true,
article: "http://en.wikipedia.org/wiki/France"
},
{
continent: "South America",
countryName: "Brazil",
countryCode: "BR",
area: 8511965,
population: 188078227,
gdp: 1556000,
independence: "1822-09-07",
government: "federative republic",
government_desc: 3,
capital: "Washington, DC",
members_g8: false,
article: "http://en.wikipedia.org/wiki/Brazil"
},
{
continent: "North America",
countryName: "Canada",
countryCode: "CA",
area: 9984670,
population: 33098932,
gdp: 1114000,
independence: "1867-07-01",
government: "constitutional monarchy with parliamentary democracy and federation",
government_desc: 1,
capital: "Ottawa",
members_g8: true,
article: "http://en.wikipedia.org/wiki/Canada"
},
{
continent: "North America",
countryName: "Mexico",
countryCode: "MX",
area: 1972550,
population: 107449525,
gdp: 1067000,
independence: "1810-09-16",
government: "federal republic",
government_desc: 2,
capital: "Mexico (Distrito Federal)",
members_g8: false,
article: "http://en.wikipedia.org/wiki/Mexico"
}
]
}
}
------------------------End Country fetch.xml
-------country_add.xml
{
response: {
status: 0,
data: [
{
countryCode: "A1",
countryName: "Saved Value",
capital: "Saved Value",
continent: "Saved Value"
}
]
}
}
------------------------End country_add.xml
I have been playing with smartclient and found that there are some problems when a RestDataSource has its dataFormat defined as "json". When this happens, the Databound component (tested with grid and tree) will not be able to reflect any newly added or updated records.
I have tested using the isomorphic example found in my own copy of smartclient at
http://localhost:8080/isomorphic/system/reference/SmartClient_Explorer.html#restEditSave and changed the 2 files country_fetch.xml and country_add.xml accordingly.
(in your smatclient website, you can refer to this copy. http://www.smartclient.com/isomorphic/system/reference/SmartClient_Explorer.html#restEditSave).
Whenever I add "dataFormat: "json" into the datasource definition and then replace the xml data with json format. Loading JSON formatted data works without any problems. However clicking on the add button does not refresh the list data with the new entry.
Below are the data I converted from xml to json. Please confirm if this is indeed a problem or have I generate the wrong json format?
Thanks in advance
---------Section modified in the example JS
isc.RestDataSource.create({
ID:"countryDS",
dataFormat:"json",
fields:[
{name:"countryCode", title:"Code", primaryKey:true, canEdit:"false"},
{name:"countryName", title:"Country"},
{name:"capital", title:"Capital"}
],
fetchDataURL:"/isomorphic/system/reference/inlineExamples/dataIntegration/xml/responses/country_fetch_rest.xml",
addDataURL :"/isomorphic/system/reference/inlineExamples/dataIntegration/xml/responses/country_add_rest.xml",
updateDataURL:"/isomorphic/system/reference/inlineExamples/dataIntegration/xml/responses/country_update_rest.xml",
removeDataURL:"/isomorphic/system/reference/inlineExamples/dataIntegration/xml/responses/country_remove_rest.xml"
});
-----------------------------------------
------country_fetch.xml
{
response: {
status: 0,
startRow: 0,
endRow: 7,
totalRows: 7,
data: [
{
continent: "North America",
countryName: "United States",
countryCode: "US",
area: 9631420,
gdp: 1830000,
population: 298444215,
independence: "1776-07-04",
government: "federal republic",
government_desc: 2,
capital: "Washington, DC",
members_g8: true,
article: "http://en.wikipedia.org/wiki/United_states"
},
{
continent: "Europe",
countryName: "Germany",
countryCode: "GM",
area: 357021,
gdp: 1830000,
population: 82422299,
independence: "1871-01-18",
government: "federal republic",
government_desc: 2,
capital: "Berlin",
members_g8: true,
article: "http://en.wikipedia.org/wiki/Germany"
},
{
continent: "Europe",
countryName: "United Kingdom",
countryCode: "UK",
area: 60609153,
population: 298444215,
gdp: 1830000,
independence: "1801-01-01",
government: "constitutional monarchy",
government_desc: 2,
capital: "London",
members_g8: true,
article: "http://en.wikipedia.org/wiki/United_kingdom"
},
{
continent: "Europe",
countryName: "France",
countryCode: "FR",
area: 547030,
population: 298444215,
gdp: 1816000,
government: "republic",
government_desc: 2,
capital: "Paris",
members_g8: true,
article: "http://en.wikipedia.org/wiki/France"
},
{
continent: "South America",
countryName: "Brazil",
countryCode: "BR",
area: 8511965,
population: 188078227,
gdp: 1556000,
independence: "1822-09-07",
government: "federative republic",
government_desc: 3,
capital: "Washington, DC",
members_g8: false,
article: "http://en.wikipedia.org/wiki/Brazil"
},
{
continent: "North America",
countryName: "Canada",
countryCode: "CA",
area: 9984670,
population: 33098932,
gdp: 1114000,
independence: "1867-07-01",
government: "constitutional monarchy with parliamentary democracy and federation",
government_desc: 1,
capital: "Ottawa",
members_g8: true,
article: "http://en.wikipedia.org/wiki/Canada"
},
{
continent: "North America",
countryName: "Mexico",
countryCode: "MX",
area: 1972550,
population: 107449525,
gdp: 1067000,
independence: "1810-09-16",
government: "federal republic",
government_desc: 2,
capital: "Mexico (Distrito Federal)",
members_g8: false,
article: "http://en.wikipedia.org/wiki/Mexico"
}
]
}
}
------------------------End Country fetch.xml
-------country_add.xml
{
response: {
status: 0,
data: [
{
countryCode: "A1",
countryName: "Saved Value",
capital: "Saved Value",
continent: "Saved Value"
}
]
}
}
------------------------End country_add.xml
Comment