Grid Dropdown Editor Problem with New Version!

6 posts, 0 answers
  1. Martin
    Martin avatar
    9 posts
    Member since:
    Nov 2014

    Posted 03 Jul 2015 Link to this post

     According to the example http://demos.telerik.com/kendo-ui/grid/editing-custom I implemented a dropdown editor in a Grid popup editor with Kendo Grid version 2014.3.1411.

    Now, with version 2015.2.624 it does not set the dropdown list to the value the item already has. Wasted 2 hours to find out :-((

    Does anyone have an idea why and for what reason we have this degradation of code with the new version? Thanks in advance!

    Martin

     Here is the code that works in the old version: 

    function mt_measurandDropDownEditor(container, options) {
        $('<input id=\"dde_mt_measurand\" name=\"MT_MEASURAND\" data-text-field=\"TY_LONGNAME\" data-value-field=\"TY_ID\"  data-bind=\"value:' + options.field + '\" />')
        .appendTo(container)
        .kendoDropDownList({dataTextField: \"TY_LONGNAME\", dataValueField: \"TY_ID\", name: 'MT_MEASURAND', autoBind: false, optionLabel: '--- bitte wählen ---',
            dataSource: {
                type: \"odata\",
                transport: {
                    read: {
                        url: function (data) {
                            return odataServiceName + 'Codes';
                        },
                        dataType: 'json'
                    },
                    parameterMap: function (data, action) {
                        if (action === 'read') {
                            var domainFilter = \"TY_DOMAIN eq guid'1e68ffd6-aaaa-4558-94e1-23df53e5a6c6'\";
                            var d = kendo.data.transports.odata.parameterMap(data);
                            if (d.$filter) {
                                d.$filter = domainFilter + \" and \" + d.$filter ;
                            } else {
                                d.$filter = domainFilter;
                            }
                            return d;
                        } else {
                            return data;
                        }
                    }
                },
                schema: {
                    data: function(data) {
                        return data;
                    },
                    total: function(data) {
                        return data.length;
                    },
                    model: {
                        id: \"TY_ID\",
                        fields: {
                            TY_ID: { type: 'string' },
                            TY_NAME: { type: 'string' },
                            TY_LONGNAME: { type: 'string' }
                        }
                    }
                },
     
                change: function(data) {
                    kendo.bind($('#dde_mt_measurand'), data.items);
                    $('#dde_mt_measurand').attr('dataloaded', 'true');
                }
            }
        })
    };

  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 07 Jul 2015 Link to this post

    Hi Martin,

    I checked the custom editor demo page but did not manage to observe any issues.

    Did you checked the JavaScript console for any errors that may give us a clue what exactly is going wrong?

    On a side note, it is unclear to me what is the purpose of the code executed in the change event handler:
    change: function(data) {
        kendo.bind($('#dde_mt_measurand'), data.items);
        $('#dde_mt_measurand').attr('dataloaded', 'true');
    }

    I assume that the issue may be related to the fact that kendo.bind is called manually for the editor input. This is not a recommended approach. Could you please try to remove this code and see if the issue still persists?

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Martin
    Martin avatar
    9 posts
    Member since:
    Nov 2014

    Posted 07 Jul 2015 in reply to Alexander Valchev Link to this post

    Hi Alexander

    When removing the change function, there is a JQuery error:

    SCRIPT5022: Syntax error, unrecognized expression: .async_[object Object]
    File: jquery, line: 1, column: 29853

    And if I run this with the latest 2015 version, there is no error on the console, but when editing, the original values are not shown in the list (see attached image). Only the standard text is shown in lists, where the original record had a NULL value.

     So if removing the change function, the problem comes down to the question, why the selected value is not shown and how can we tell the list to show that value. Could eventually be a timing problem as the original value is here while the list is still fetched from the server and when it is fully loaded, some refresh call is not issued.

    How can this be fixed?

    Thanks and best regards

     Martin

     

  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 09 Jul 2015 Link to this post

    Hello Martin,

    Could you try removing the autoBind option or setting it to true? In previous versions the value binding used to force reading the data event if the option is set to false. In the latest version the autoBind option is respected and the data will not be read until the dropdownlist is opened.

    Regards,
    Daniel
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Martin
    Martin avatar
    9 posts
    Member since:
    Nov 2014

    Posted 09 Jul 2015 in reply to Daniel Link to this post

    Hi Daniel

    Thank you. The autobind option is it! I've found it out myself some hours ago.

    Though, I'm quite happy with Kendo UI, it's a huge waste of time in programming when proper documentation is not available. This change of the autobind option without an update of the examples (the only "reliable" source of documentation) is symptomatic for the innumberable small items that do not work according to expectation or you only find out by hacking for hours and hours.

    In fact, it would be a brilliant idea to plan a future release just to clean up inconsistencies beteween widgets which then simplifies the documentation. Or in other words: what is the use of a new feature in a widget if nobody tells you that it is there?

    Thanks again an best regards

     Martin

  7. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 13 Jul 2015 Link to this post

    Hello Martin,

    The behaviour was caused by a bug in the source of the framework. As my colleague Daniel said:

    In previous versions the value binding used to **force reading the data event if the option is set to false**. In the latest version the autoBind option is respected and the data will not be read until the dropdownlist is opened.

    In other words the autoBind option should always prevent the widget from reading its dataSource. This is applicable for all Kendo UI widgets. If the autoBind option was not working, this is due to a bug which we already fixed.

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready