问题描述:

On clicking Edit button on a Page a method is triggered and a window which uses a kendo template is opened . One of the control on the kendo window is Kendo dropdown list which needs to have values comming from the webmethod.The error i am getting on clicking of the edit button is 'Object doesn't support property or method 'slice'. Below is my code for the Edit button.

function edit(item) {

var editTemplate = kendo.template($("#editTemplate").html());

var treeview = $("#treeview").data("kendoTreeView");

var selectedNode = treeview.select();

var node = treeview.dataItem(selectedNode);

$("<div/>")

.html(editTemplate({ node: node}))

.appendTo("body")

.kendoWindow({

modal: true,

activate:function(){

$("#roles").kendoDropDownList({

dataTextField: "Countryname",

dataValueField: "CountryId",

dataSource: {

transport: {

read: {

url: "/Services/MenuServices.asmx/getcountries",

contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON

type: "POST", //use HTTP POST request as the default GET is not allowed for ASMX

}

}

}

})

},

deactivate: function () {

this.destroy();

}

})

.on("click", ".k-primary", function (e) {

var dialog = $(e.currentTarget).closest("[data-role=window]").getKendoWindow();

var textbox = dialog.element.find(".k-textbox");

var Id = $('#ID').val();

node.set("id", Id);

dialog.close();

var treenode = treeview.dataSource.get(itemid);

treenode.set("id", Id);

treenode.ID = Id;

console.log(JSON.stringify(treenode));

})

}

IS there any property for Kendo window that triggers this service when its opened.Right now i am using activate event but its not working.tried using 'Open' event also.

Thanks

网友答案:

I added the Schema part to the datasource and it worked.

schema: {
                        data: function (response) {
                            return JSON.parse(response.d); // ASMX services return JSON in the following format { "d": <result> }. 
                        },
                        model: { // define the model of the data source. Required for validation and property types.
                            id: "CountryId",
                            fields: {
                                CountryId: { editable: false, nullable: false, type: "string" },
                                Countryname: { editable: true, nullable: true, type: "string" },
                               }
                        },
                    },
相关阅读:
Top