Unexpected number error when using a function for DataSource transport update

4 posts, 0 answers
  1. Gareth
    Gareth avatar
    1 posts
    Member since:
    Apr 2013

    Posted 15 Apr 2013 Link to this post

    I am using:
     - Kendo UI Complete 2013.1.319
     - Windows 7 64-bit
     - Google Chrome 26.0.1410.64 m
     - The jQuery bundled with Kendo

    I have the following HTML:
    <div id="app"></div>
    <script type="text/x-kendo-template" id="users">
      <div data-role="grid" data-filterable="true" data-editable="true" data-sortable="true" data-bind="source: usersSource" data-columns="[{ field:'username', title:'Username' }, { field:'fullname', title:'Full Name' }, { command:'destroy' }]"></div>
    And the following JavaScript:
    var usersModel = kendo.observable({
        // the users data
        usersSource:new kendo.data.DataSource({
            schema:{ model:{ id:"_id" } },
                create:{ url:"/user", dataType:"json", type:"POST" },
                    url:function (user) {
                        return "/user/" + user._id + "/" + user._rev
                read:{ url:"/users", dataType:"json" },
                update:{ url:"/user", dataType:"json", type:"POST" }
    var usersView = new kendo.View("users", { model:usersModel});
    var router = new kendo.Router({
        init:function () {
    $(function () {
    This all works as expected - I can update the data in the grid. I am however storing the data in couchdb and need to update the data source with the new revision number after create and update events are complete.

    I think that I need to replace the object I'm using with create and update with a function to allow me to do this. I have attempted to do this with just a simple function as shown below:
    /* trimmed */
    /* trimmed */
    This however results in an error on the JavaScript console when I modify a record in the grid:
    Uncaught SyntaxError: Unexpected number     kendo.web.min.js:9
    st.setter                                   kendo.web.min.js:9
    tt.extend._set                              kendo.web.min.js:11
    zt.extend.accept                            kendo.web.min.js:11
    tt.extend._accept                           kendo.web.min.js:11
    (anonymous function)                        kendo.web.min.js:11
    (anonymous function)                        jquery.min.js:3
    c                                           jquery.min.js:3
    p.fireWith                                  jquery.min.js:3
    i.(anonymous function)                      jquery.min.js:3
    a.(anonymous function).call.q.success       kendo.web.min.js:11
    c                                           jquery.min.js:3
    p.fireWith                                  jquery.min.js:3
    k                                           jquery.min.js:5
    r                                           jquery.min.js:5
    Where is the mistake I'm making? I also tried copy-and-pasting the exact declaration from the documentation for transport.update with the same results.
  2. Alexander Valchev
    Alexander Valchev avatar
    2873 posts

    Posted 17 Apr 2013 Link to this post

    Hi Gareth,

    Such error occurs when the transport definitions are inconsistent. In other words, if you would like to use custom transport method, all transport types should be defined as functions.

    Having a standard read transport and custom update is not supported. Please configure all transports as functions and let me know if the error still occurs.

    Kind regards,
    Alexander Valchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Stuart
    Stuart avatar
    2 posts
    Member since:
    May 2013

    Posted 16 Apr 2015 in reply to Alexander Valchev Link to this post

    It would definitely be worth including that information in the documentation, it would have saved me a lot of time.
  4. Alexander Valchev
    Alexander Valchev avatar
    2873 posts

    Posted 20 Apr 2015 Link to this post

    Hello Stuart,

    Thank you for the feedback. At which place do you think it would be best to include this information?

    If you wish you may event include it and make a pull request, the documentation is public and open source.

    Alexander Valchev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top