How to change edit mode(pop-up+inline) dynamically in kendo ui grid on click of button in grid?

匆匆过客 提交于 2019-12-24 07:13:02

问题


I am using mvc4 application .On one of my page i am using kendo grid.I want to add two buttons for editing, one is used for editing in pop-up and other for inline editing.

I want to change the grid edit mode dynamically on click of button.

Can any one help me out ?


回答1:


You cannot have two editing modes at a time.

As a work-around you can use the InLine editing + template column with a button inside which on click opens a window.

You can set the content of the window to be a template and bind it with the dataItem for that row when the buttons is clicked.




回答2:


If you want to change dynamically the edit mode for all rows in a Grid you can do:

Button and Grid definition:

<a href="#" id="popup" class="k-button">Popup</a>
<a href="#" id="inline" class="k-button">Inline</a>
<div id="grid"></div>

Grid initialization:

var grid = kendoGrid({
    dataSource: dataSource,
    columns: [
        { command: ["edit", "destroy"], title: "&nbsp;" },
        { field: "field1", title: "Field1" },
        { field: "field2", title: "Field2" },
    ],
    editable  : "popup"
}).data("kendoGrid");

Buttons initialization:

$("#popup").on("click", function () {
    grid.options.editable = "popup";
});
$("#inline").on("click", function () {
    grid.options.editable = "inline";
});

When you click on either of these buttons, you select the edit mode as inline or popup.



来源:https://stackoverflow.com/questions/14029405/how-to-change-edit-modepop-upinline-dynamically-in-kendo-ui-grid-on-click-of

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!