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

DataSource mysteriously adding an "M" character to my ID upon update

2 Answers 82 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 24 Apr 2014, 08:05 PM
When I submit an update given my data source, it generates the following HTTP request. Note the TEIID_TEST(2M) part - it should just be 2, corresponding to a numeric ID of 2: 

PUT http://amr-dsiprod05:8080/odata/SDA/TEIID_TEST HTTP/1.1
Content-Type: application/json
Accept-Language: en-us
Authorization: Basic dXNlcjp1c2Vy
Accept: application/json, text/javascript, */*; q=0.01
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; MS-RTC LM 8)
Host: amr-dsiprod05:8080
Content-Length: 147
Connection: Keep-Alive
Pragma: no-cache
 
{"__metadata":{"uri":"http://amr-dsiprod05:8080/odata/SDA/TEIID_TEST(2M)","type":"SDA.TEIID_TEST"},"NAME":"test","FAVORITE_COLOR":"Blues","ID":"2"}

Here's my code:

<script type="text/javascript"> 
    jQuery.support.cors = true;
    var call = $.ajax({
        url: "http://amr-dsiprod05:8080/odata/SDA/TEIID_TEST",
        type: "GET",
        headers: {
            Authorization: "Basic dXNlcjp1c2Vy"
        },
        dataType: "json",
        success: function(data){
            var results = data.d.results;
            var len = results.length;
            var text = '<p>Successfully fetched ' + len + ' rows from the database</p>';
            $('#RESULT').html(text);
        },
        error: function(err){
            //alert(err.statusText);
            $('#RESULT').html('<p>Failed to fetch data due to ' + err.statusText);
        }
    });
    call.done(function (data, textStatus, jqXHR) {
        $('#example').dataTable({
            "bDestroy": true,
            "bProcessing": true,
            "aaData": data.d.results,
            "aoColumns": [
                { "mData": "NAME" },
                { "mData": "FAVORITE_COLOR" },
                { "mData": "ID" }
            ]
          });
    });
    call.fail(function (jqXHR,textStatus,errorThrown){
        alert("Error retrieving Tasks: " + jqXHR.responseText);
    });
</script>

Thoughts? Why does the M appear?

2 Answers, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 1
answered on 24 Apr 2014, 08:59 PM
Edit: wow, how silly of me. I was working with DataTables for my first iteration of this project and pasted that code. Instead, here's my latest code:

jQuery.support.cors = true;
 
$(function () {
 
    var productsDataSource = new kendo.data.DataSource({
        type: "odata",
        serverFiltering: true,
        serverPaging: true,
        serverSorting: true,
        pageSize: 10,
        transport: {
            read: {
                url: "http://amr-dsiprod05:8080/odata/SDA/TEIID_TEST",
                type: "GET",
                headers: {
                    Authorization: "Basic dXNlcjp1c2Vy"
                },
                dataType: "json"
            },
            update: {
                url: "http://amr-dsiprod05:8080/odata/SDA/TEIID_TEST",
                type: "PUT",
                headers: {
                    Authorization: "Basic dXNlcjp1c2Vy"
                },
                dataType: "json",
                contentType: "application/json"
            },
            create: {
                url: "http://amr-dsiprod05:8080/odata/SDA/TEIID_TEST",
                type: "POST",
                headers: {
                    Authorization: "Basic dXNlcjp1c2Vy"
                },
                dataType: "json"
            },
            destroy: {
                url: "http://amr-dsiprod05:8080/odata/SDA/TEIID_TEST",
                type: "DELETE",
                headers: {
                    Authorization: "Basic dXNlcjp1c2Vy"
                },
                dataType: "json"
            }
        },
         
        schema: {
            model: {
                id: "ID",
                fields: {
                    ID: {
                        editable: true,
                        nullable: true
                    },
                    NAME: {
                        editable: true,
                        nullable: true
                    },
                    FAVORITE_COLOR: {
                        editable: true,
                        nullable: true
                    }
                }
            }
        }       
    });  
 
    productsDataSource.read();
 
    $("#name").kendoAutoComplete({
        autoBind: false,
        dataSource: productsDataSource,
        dataTextField: "NAME",
        filter: "startswith",
        minLength: 2
    });
     
    $("#grid").kendoGrid({
        dataSource: productsDataSource,
        autoBind: false,
        pageable: true,
        height: 300,
        selectable: true,
        editable: true,
        toolbar: ["create","save","cancel"],
        columns: [
            { field: "NAME", title: "User Name"},
            { field: "FAVORITE_COLOR", title:"FAVORITE_COLOR" },
            { field: "ID", width: "100px" },
            { command: "destroy" }
        ]
    });
});
0
Kiril Nikolov
Telerik team
answered on 28 Apr 2014, 11:03 AM
Hello Daniel,

I was not able to access your remote services, and therefore reproduce the issue that you are referring to. Please check the following test jsBin that I created, and let me know how I can access your remote data, so I can reproduce the issue (or you can put some of your sample data in the jsBin and updated it) :

http://jsbin.com/gamev/1/edit

Regards,
Kiril Nikolov
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
Daniel
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or