Workaround for objects with IDs as arrays?

2 posts, 0 answers
  1. Ryan
    Ryan avatar
    1 posts
    Member since:
    Feb 2016

    Posted 08 Feb 2016 Link to this post

    I am working a set of data that contains arrays as IDs. I need some help working around this as it appears unsupported and breaks some things.

    Example item from the first set of data:

      "name":"Another VIP-VID-INPUT-1",

    This data is referenced from second set of data which uses the same array IDs to refer to the first set. Example item from the second set of data:

      "name":"Link 02",

    For starters I am populating a Grid with the second set of data. I use a column.template to replace "head_port_id" and "tail_port_id" with the relevant "name" field from the first set of data. This works fine.

    The problem arises when I try to use a DropDownMenu inside column.editor for the "head_port_id" and "tail_port_id" columns. Clicking the cell causes an error. 

    editor: function(container, options) {
        var editor = $('<input />')
            .attr('name', options.field) // "head_port_id"
            .attr('required', 'required')
            .attr('data-bind', 'value:' + options.field); // "head_port_id"
            autoBind: false,
            dataSource: data.ports.datasource, // the first set of data
            dataTextField: 'name',
            dataValueField: 'id'
      The error I get looks like this:

    Uncaught TypeError: o[s].get is not a function
    E.widget.value.v.extend.refresh @ kendo.all.js:8886
    I.extend.bind @ kendo.all.js:8153
    w.extend.applyBinding @ kendo.all.js:9146
    I.extend.bind @ kendo.all.js:9096
    a @ kendo.all.js:9239
    a @ kendo.all.js:9247
    a @ kendo.all.js:9247
    s @ kendo.all.js:9262
    c.extend.refresh @ kendo.all.js:36822
    c.extend.init @ kendo.all.js:36731
    (anonymous function) @ kendo.all.js:2382
    b.extend.each @ jquery-1.9.1.min.js:3
    b.fn.b.each @ jquery-1.9.1.min.js:3
    e.fn.(anonymous function) @ kendo.all.js:2381
    ue.ui.DataBoundWidget.extend.editCell @ kendo.all.js:45210
    (anonymous function) @ kendo.all.js:45168
    b.event.dispatch @ jquery-1.9.1.min.js:3
    v.handle @ jquery-1.9.1.min.js:3

    Since I have the minified code it's difficult to debug this, even though I can see the full source code (a source map is loaded I assume). Breakpoints and scope vars aren't cooperating.

    Anyway I had an idea which was to define a "parse" function for all of the array ID fields, in my Models. It simply converted the ID arrays .toString(). This works pretty well except that it has a fatal flaw in which the data I send to the relevant service is now invalid, since the service is expecting arrays and not strings.

    How can I convert these IDs back to arrays, ideally without doing this in the DataSource transport functions (update, create, etc)? I have a generic DataSource wrapper that I am using to wrap our own CRUD interface.. I don't want it to have special cases in it for this once type of data.

  2. T. Tsonev
    T. Tsonev avatar
    2794 posts

    Posted 11 Feb 2016 Link to this post


    Sorry for the delay.

    I'm pretty certain that we don't support arrays for ID values. These values should be comparable with simple equality operators and arrays do not satisfy that.
    I can't see that clearly stated in the Model documentation and will make sure to add it there.

    Apologies for the caused inconvenience.

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