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

Grid Dropdown Editor Problem with New Version!

5 Answers 230 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 03 Jul 2015, 02:44 PM

 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');
            }
        }
    })
};

5 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 07 Jul 2015, 08:16 AM
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!
 
0
Martin
Top achievements
Rank 1
answered on 07 Jul 2015, 10:18 AM

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

 

0
Daniel
Telerik team
answered on 09 Jul 2015, 07:57 AM
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!
 
0
Martin
Top achievements
Rank 1
answered on 09 Jul 2015, 11:29 AM

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

0
Alexander Valchev
Telerik team
answered on 13 Jul 2015, 07:15 AM
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!
 
Tags
Grid
Asked by
Martin
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Martin
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or