jQuery UI Widgets › Forums › Plugins › Data Adapter › XML – double data in DataTable
Tagged: data, data adapter, dataadapter, jqxDataAdapter, record, tag, XML
This topic contains 3 replies, has 3 voices, and was last updated by Dimitar 10 years, 9 months ago.
-
Author
-
Good morning,
<script type=”text/javascript”>
$(document).ready(function () {
var url = “./database/Collection.xml”;var source =
{
datatype: “xml”,
datafields: [
{ name: ‘ID’, map: ‘ID’, type: ‘string’ },
{ name: ‘Title’, map: ‘Title’, type: ‘string’ },
{ name: ‘RatingAge’, map: ‘RatingAge’, type: ‘string’ },
{ name: ‘RunningTime’, map: ‘RunningTime’, type: ‘string’ }
],
root: “Collection”,
record: “Collection>DVD”,
id: ‘ID’,
url: url,
pagenum: 44,
pagesize: 20,
sortcolumn: ‘Title’,
sortdirection: ‘asc’
};var dataAdapter = new $.jqx.dataAdapter(source);
$(“#dataTable”).jqxDataTable(
{
width: 1000,
height: 750,
source: dataAdapter,
sortable: true,
pageable: true,
columns: [
{
text: ‘Bild’, datafield: ‘ID’, width: 80, align: ‘center’,
cellsRenderer: function (row, column, value, rowData)
{
var image = “<div></div>”;
return image;
}
},
{
text: ‘Details’, datafield: ‘Title’,
cellsRenderer: function (row, column, value, rowData)
{
var details = “<div><b>Titel:</b> ” + rowData.Title + “</div>”;
details += “<div><b>Länge:</b> ” + rowData.RunningTime + ” min.</div>”;
return details;
}
},
{
text: ‘FSK’, datafield: ‘RatingAge’, width: 50, align: ‘center’,
cellsRenderer: function (row, column, value, rowData)
{
if (rowData.RatingAge < 3) {rowData.RatingAge = 0};
if (rowData.RatingAge = 15) {rowData.RatingAge = 16};
var fsk = “<div></div>”;
return fsk;
}
}
]
});
});
</script>… output is ok but I have double entries. I know the problem with this XML file but don´t know how to resolve this. I cannot change the XML file.
<Collection>
<DVD>
<ProfileTimestamp>2009-04-01T16:56:55.000Z</ProfileTimestamp>
<ID>044005622621.5</ID>
<MediaTypes>
<DVD>true</DVD>
<HDDVD>false</HDDVD>
<BluRay>false</BluRay>
</MediaTypes>
<UPC>044005-622621</UPC>
<CollectionNumber/>
<CollectionType IsPartOfOwnedCollection=”true”>Owned</CollectionType>
<Title>The Game</Title>
<DistTrait/>
…
</DVD>
</Collection>The “DVD” is twice. Are there a solution that the output is without the second “DVD” tag?
Thanks a lot in advance
AndreasJust passing by, but does record: “Collection>DVD” not select all “Collection” “DVD” descendants? maybe using
root: “Collection”,
record: “DVD”,and datafields without mapping
datafields: [
{ name: ‘ID’, type: ‘string’ },
{ name: ‘Title’, type: ‘string’ },
{ name: ‘RatingAge’, type: ‘string’ },
{ name: ‘RunningTime’, type: ‘string’ }
],Solves it?
(I’m also struggled a little bit with this, maybe it helps)I´ve changed it but doesn´t solved the problem.
Hello arubbert,
The issue comes from the XML data. The only solution is to change one of the DVD tags to something else.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.