javascript - Required validation in combobox inside Kendo Grid -
i have kendo grid has combo boxes on inline editing. when add required validation combo box not working. have created sample in js filder in following url.
var products = [ { "productid": 1, "productname": "chai", "category": { "categoryid": 1, "categoryname": "beverages" }, "unitprice": "18.00" }, { "productid": 2, "productname": "chang", "category": { "categoryid": 1, "categoryname": "beverages" }, "unitprice": "19.00" }, { "productid": 3, "productname": "aniseed syrup", "categoryid": 2, "category": { "categoryid": 1, "categoryname": "beverages" }, "unitprice": "10.00" }, { "productid": 4, "productname": "chef anton's cajun seasoning", "category": { "categoryid": 2, "categoryname": "condiments" }, "unitprice": "22.00" }, { "productid": 5, "productname": "chef anton's gumbo mix", "category": { "categoryid": 2, "categoryname": "condiments" }, "unitprice": "21.35" }, { "productid": 6, "productname": "grandma's boysenberry spread", "category": { "categoryid": 2, "categoryname": "condiments" }, "unitprice": "25.00" }]; var datasource = new kendo.data.datasource({ pagesize: 30, data: products, batch:true, schema: { model: { id: "productid", fields: { productid: { editable: false, nullable: true }, productname: { validation: { required: true } }, category: {// defaultvalue: { categoryid: 1, categoryname: "beverages"} }, unitprice: { type: "number", validation: { required: true, min: 1 } } } } } }); $("#grid").kendogrid({ datasource: datasource, navigatable:true, toolbar:["create", "save","cancel"] , columns: [ "productname", { field: "category", editor: comboeditor, template: "#=category.categoryname#" }, { field: "unitprice", format: "{0:c}" } ], editable: true }); function comboeditor(container, options) { debugger; $('<input data-text-field="categoryname" required="required" validationmessage="required" data-value-field="categoryid" data-bind="value:' + options.field + '"/>').appendto(container).kendocombobox({ autobind: false, datasource: { type: "odata", transport: { read: "http://demos.kendoui.com/service/northwind.svc/categories" } } }) }
is there added validation work properly.
thanz
use this
function comboeditor(container, options) { $('<input required="required" name="' + options.field + '"/>').appendto(container).kendocombobox({ autobind: false, datasource: { type: "odata", transport: { read: "http://demos.kendoui.com/service/northwind.svc/categories" } } }); $('<span class="k-invalid-msg" data-for="' + options.field + '"></span>').appendto(container); }
hope you:)
Comments
Post a Comment