سؤال

i have a kendo grid whose detail rows are populated with editable grids of popup creation mode. Inside each of those popup creation windows i use, among others, a kendo autocomplete widget:

                    $("#labResponsibleRegistryNo").kendoAutoComplete({
                        dataSource: labResponsiblesDS,
                        dataTextField: "fullname",                            
                        template: "<div class='labResponsiblesTemplate'>\
                                        <span class='template_fullname'> #= lastname + ' ' + firstname #</span>\
                                        <div class='template_details'>\
                                            <span> ΑΜ </span>\
                                            <span class='template_data'> #= registry_no # </span>\
                                        </div>\
                                    <div>",
                        minLength: 3
                        //suggest: true,
                    });

which i bind with the labResponsiblesDS datasource, below:

        var labResponsiblesDS=  new kendo.data.DataSource({
            serverFiltering: true,
            transport: {
                read: {
                    url: "api/workers",
                    type: "GET",
                    data: {},
                    dataType: "json"
                },
                parameterMap: function(data, type) {
                    if (type === 'read') {
                        data["worker"] = data.filter.filters[0].value;
                        delete data.filter;
                    }
                    return data;
                }
            },
            schema: {
                data: "data",
                total: "total"
            },
            requestEnd: function(e) {
                console.log("labResponsiblesDS requestEnd", e);
                if(e.response.data.length > 0){
                    var results_no = e.response.data.length;
                    for(var i=0;i<results_no;i++){
                        e.response.data[i].fullname = e.response.data[i].lastname + " " + e.response.data[i].firstname;
                    }
                }
            }
        });

In labResponsiblesDS 's request End event, I create in each one of the results returned from the server, an extra field "fullname" which is the concatenation of two of the fields returned "lastname" and "firstname". "fullname" is used in the autocomplete's dataTextField.

My problem is that after achieving the autocomplete widget's desirable functionality inside some nested grid's popup create window, when i close that popup and reopen it or open another nested grid's popup, the requestEnd event FAILS to fire. Any advice would be much appreciated.THanks in advance

هل كانت مفيدة؟

المحلول

Insert the fullname value directly into your schema. You would just need to implement the schema.data as an anonymous function, and form the fullname there:

schema: {
    data: function(data) {
        for (var i = 0; i < data.length; ++i) {
            data[i].fullname = data[i].lastname + " " + data[i].firstname;
        }
        return data;
    },
    total: "total"
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top