This is a migrated thread and some comments may be shown as answers.

Kendo UI Datasource FIeld with Array

1 Answer 370 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
Iron
Iron
John asked on 18 Feb 2014, 01:39 AM
I am having an issue with getting the values of an array within the kendo ui datasource object. I have searched and tried many things to fix, but have not found a solution in 3 weeks. Basically I want to get the values of an array named 'base64img' that is assigned as a field in the Kendo UI datasource, but I have been unable to get access to the data of the array value.

Here are all my stats: (if there are errors in response, please ignore as I modified for security purposes) XML Response -

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><retrieveIncidentResponse xmlns="http://lal.lala.com/lala/messages/"><incidentStructure><geoLoc>LALA1</geoLoc><eventName>PARTY</eventName><incidentStatus>OPEN</incidentStatus><incidentCompltnDate>2012-01-02</incidentCompltnDate>incidentStructure><imageURI>IMAG0001.jpg</imageURI><imageURI>IMAG0002.jpg</imageURI><imageURI>IMAG0003.jpg</imageURI><imageURI>IMAG0004.jpg</imageURI><imageURI>IMAG0005.jpg</imageURI><imageBase64>/9j/4AAQSkZJRgABAQAAAQABAAD</imageBase64><imageBase64>/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkM</imageBase64><imageBase64>EQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJC</imageeBase64><imageBase64>IeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eH</imageBase64>

Kendo DataSource Code:

var parser = new DOMParser();
var xmlDoc = parser.parseFromString(soapXMLResponse, "application/xml");
var dsIncPictures = new kendo.data.DataSource({
    error: function (e)
    {
        console.log("ds error: " + e.status);
    },
        data: xmlDoc,
        schema:
        {
        type: "xml",
        data: "soapenv:Envelope/soapenv:Body/retrieveIncidentResponse",
        model:
            {
            fields:
            {
            imageURI: "imageURI",
            imageBase64: "imageBase64"
            },
        hasChildren: true
        }
        },
    pageSize: 50
    });

My attempts to get to the values:
/*$drt.globalEditIncWPics.fetch(function()
        {
            $drt.globalEditIncWPics._data(0).imageBase64(0).val;
            $drt.globalEditIncWPics.get("imageURI[0]");
            var field = $drt.globalEditIncWPics.get("imageURI[0]").imageURI[0].length;
            console.log($drt.globalEditIncWPics.get().imageURI(0));
            var field = $drt.globalEditIncWPics.at(0);
            console.log("VALUE: '" + field.text + "'");
            soapRequest.append(bind.soapRequestMessageFields(field.FieldName, field.value));
        });*/
        /*$drt.globalEditIncWPics.fetch();
        for (var idx = 0;idx<=$drt.globalEditIncWPics.length;idx++)
        {
            $drt.globalEditIncWPics.data[0].imageBase64[0].value;

        }*/

This is the results of the object Google developer tools:


I am having an issue with getting the values of an array within the kendo ui datasource object. I have searched and tried many things to fix, but have not found a solution in 3 weeks. Basically I want to get the values of an array named 'base64img' that is assigned as a field in the Kendo UI datasource, but I have been unable to get access to the data of the array value. Here are all my stats: (if there are errors in response, please ignore as I modified for security purposes) XML Response -

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><retrieveIncidentResponse xmlns="http://lal.lala.com/lala/messages/"><incidentStructure><geoLoc>LALA1</geoLoc><eventName>PARTY</eventName><incidentStatus>OPEN</incidentStatus><incidentCompltnDate>2012-01-02</incidentCompltnDate>incidentStructure><imageURI>IMAG0001.jpg</imageURI><imageURI>IMAG0002.jpg</imageURI><imageURI>IMAG0003.jpg</imageURI><imageURI>IMAG0004.jpg</imageURI><imageURI>IMAG0005.jpg</imageURI><imageBase64>/9j/4AAQSkZJRgABAQAAAQABAAD</imageBase64><imageBase64>/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkM</imageBase64><imageBase64>EQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJC</imageeBase64><imageBase64>IeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eH</imageBase64>

Kendo DataSource Code:

var parser = new DOMParser();
var xmlDoc = parser.parseFromString(soapXMLResponse, "application/xml");
var dsIncPictures = new kendo.data.DataSource({
    error: function (e)
    {
        console.log("ds error: " + e.status);
    },
        data: xmlDoc,
        schema:
        {
        type: "xml",
        data: "soapenv:Envelope/soapenv:Body/retrieveIncidentResponse",
        model:
            {
            fields:
            {
            imageURI: "imageURI",
            imageBase64: "imageBase64"
            },
        hasChildren: true
        }
        },
    pageSize: 50
    });

My attempts to get to the values:
/*$drt.globalEditIncWPics.fetch(function()
        {
            $drt.globalEditIncWPics._data(0).imageBase64(0).val;
            $drt.globalEditIncWPics.get("imageURI[0]");
            var field = $drt.globalEditIncWPics.get("imageURI[0]").imageURI[0].length;
            console.log($drt.globalEditIncWPics.get().imageURI(0));
            var field = $drt.globalEditIncWPics.at(0);
            console.log("VALUE: '" + field.text + "'");
            soapRequest.append(bind.soapRequestMessageFields(field.FieldName, field.value));
        });*/
        /*$drt.globalEditIncWPics.fetch();
        for (var idx = 0;idx<=$drt.globalEditIncWPics.length;idx++)
        {
            $drt.globalEditIncWPics.data[0].imageBase64[0].value;

        }*/

This is the results of the object Google developer tools: Nevermind I was told that my reputation wasn't high enough to post picture. pasting code from developer tool (nevermind it takes up too much space): basically _prestineData has two arrays one called imageBase64 and imageURI in the 0|1 array spot and the values are shown as #text in each child array spot (0,1,2,3, etc).

I am having an issue with getting the values of an array within the kendo ui datasource object. I have searched and tried many things to fix, but have not found a solution in 3 weeks. Basically I want to get the values of an array named 'base64img' that is assigned as a field in the Kendo UI datasource, but I have been unable to get access to the data of the array value. Here are all my stats: (if there are errors in response, please ignore as I modified for security purposes) XML Response -

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><retrieveIncidentResponse xmlns="http://lal.lala.com/lala/messages/"><incidentStructure><geoLoc>LALA1</geoLoc><eventName>PARTY</eventName><incidentStatus>OPEN</incidentStatus><incidentCompltnDate>2012-01-02</incidentCompltnDate>incidentStructure><imageURI>IMAG0001.jpg</imageURI><imageURI>IMAG0002.jpg</imageURI><imageURI>IMAG0003.jpg</imageURI><imageURI>IMAG0004.jpg</imageURI><imageURI>IMAG0005.jpg</imageURI><imageBase64>/9j/4AAQSkZJRgABAQAAAQABAAD</imageBase64><imageBase64>/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkM</imageBase64><imageBase64>EQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJC</imageeBase64><imageBase64>IeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eH</imageBase64>

Kendo DataSource Code:

var parser = new DOMParser();
var xmlDoc = parser.parseFromString(soapXMLResponse, "application/xml");
var dsIncPictures = new kendo.data.DataSource({
    error: function (e)
    {
        console.log("ds error: " + e.status);
    },
        data: xmlDoc,
        schema:
        {
        type: "xml",
        data: "soapenv:Envelope/soapenv:Body/retrieveIncidentResponse",
        model:
            {
            fields:
            {
            imageURI: "imageURI",
            imageBase64: "imageBase64"
            },
        hasChildren: true
        }
        },
    pageSize: 50
    });

My attempts to get to the values:
/*$drt.globalEditIncWPics.fetch(function()
        {
            $drt.globalEditIncWPics._data(0).imageBase64(0).val;
            $drt.globalEditIncWPics.get("imageURI[0]");
            var field = $drt.globalEditIncWPics.get("imageURI[0]").imageURI[0].length;
            console.log($drt.globalEditIncWPics.get().imageURI(0));
            var field = $drt.globalEditIncWPics.at(0);
            console.log("VALUE: '" + field.text + "'");
            soapRequest.append(bind.soapRequestMessageFields(field.FieldName, field.value));
        });*/
        /*$drt.globalEditIncWPics.fetch();
        for (var idx = 0;idx<=$drt.globalEditIncWPics.length;idx++)
        {
            $drt.globalEditIncWPics.data[0].imageBase64[0].value;

        }*/

This is the results of the object Google developer tools: Nevermind I was told that my reputation wasn't high enough to post picture. pasting code from developer tool (nevermind it takes up too much space): basically _prestineData has two arrays one called imageBase64 and imageURI in the 0|1 array spot and the values are shown as #text in each child array spot (0,1,2,3, etc).

1 Answer, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 20 Feb 2014, 08:40 AM
Hello John,

Your XML seems to be invalid which probably caused the problem. In addition the Kendo UI datasource doesn't currently understand XML namespaces. Removing them before parsing the XML seems to make it work: http://jsbin.com/bovowiwo/1/edit

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
John
Top achievements
Rank 1
Iron
Iron
Answers by
Atanas Korchev
Telerik team
Share this question
or