or
01.function Grid_Edit(e) {02. // Return saves the row03. grid.tbody.find("input").on("keydown", function (key) {04. if (key.which === 13) {05. setTimeout(function () {06. grid.saveRow();07. }, 100);08. }09. });10. 11. // Escape cancels the row12. grid.tbody.find("input").on("keydown", function (key) {13. if (key.which === 27) {14. setTimeout(function () {15. grid.cancelRow();16. }, 100);17. }18. });19. 20. // Pressing TAB (excluding Shift + TAB) on the Quantity field also saves the row21. grid.tbody.find("input[name=Quantity]").on("keydown", function (key) {22. if (!key.shiftKey && key.which === 9) {23. setTimeout(function () {24. grid.saveRow();25. }, 100);26. }27. });28.}01.BatchCodes = [02. { URID: 900000, Code: "ABC123TEST", Quantity: 50 },03. { URID: 900001, Code: "ABC124TEST", Quantity: 25 },04. { URID: 900002, Code: "ABC125TEST", Quantity: 15 },05. { URID: 900003, Code: "ABC126TEST", Quantity: 5 }06.];07. 08.$("#GridBatchCodes").kendoGrid({09. dataSource: {10. data: BatchCodes,11. schema: {12. model: {13. id: "URID",14. fields: {15. URID: { type: "number" },16. Code: { type: "string" },17. Quantity: { type: "number" }18. }19. }20. }21. },22. edit: Grid_Edit,23. save: Grid_Save,24. columns: [25. { field: "URID", hidden: true },26. { field: "Code", title: "#" },27. { field: "Quantity", title: "Quantity" },28. { command: ["edit", "destroy"], width: "94px" }],29. toolbar: [{ name: "create" }],30. editable: "inline"31.});32. 33.function Grid_Refresh() {34. var grid = $("#GridBatchCodes").data("kendoGrid");35. 36. grid.cancelRow();37. grid.dataSource.data(BatchCodes);38.}columns: [ { field: "ProductName", title: "Product Name" }, { field: "Category", title: "Category", width: "180px", editor: categoryDropDownEditor, template: comboDisplayTemplate }, { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "130px" }, { command: "destroy", title: " ", width: "150px" } ],function comboDisplayTemplate(data){ return '<div style="color: blue">' + data.Category.description + '</div>'; } function categoryDropDownEditor(container, options) { var input = $('<input name="' + options.field + '"/>'); input.appendTo(container); input.attr("name", options.field); var combo = input.kendoComboBox({ autoBind: true, filter: "contains", placeholder: "select...", suggest: true, dataSource: combo2Data, dataTextField: "description", dataValueField: "code" });