Unplanned
Last Updated: 10 Dec 2024 09:32 by ADMIN
David
Created on: 18 Nov 2024 13:42
Category: Grid
Type: Feature Request
1
Default Paste Mode

By default, when the "paste" command is added, the default option is "insert" mode ("Paste (Insert)"). Is it possible to add an option that allows setting the default paste mode to "replace" ("Paste (Replace)")?

2 comments
ADMIN
Mihaela
Posted on: 10 Dec 2024 09:32

Hello Ben,

Thank you for your note.

While the built-in option is implemented, you can use the following workaround:

  • Handle the DataBound event of the Grid and get a reference to the Toolbar DropDownList.
  • Use the data() method of the DropDownList's DataSource to set only the "replace" option.
  • Call the value() method to update the default pasting option.
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
    .Name("grid")
    .Events(ev => ev.DataBound("onDataBound"))
)

<script>
function onDataBound() {
    var ddl = $(".k-grid-paste-action[data-role='dropdownlist']").getKendoDropDownList(); // get a reference to the DropDownList
    ddl.dataSource.data([{text: "Paste (Replace)", value: "replace"}]); // update its data
    ddl.value("replace"); // set the default option
}
</script>

Here is a REPL sample where you can test this example:

https://netcorerepl.telerik.com/cellvibx59FWPKgr14

I hope that helps.

Regards,
Mihaela
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Ben
Posted on: 04 Dec 2024 16:01
This would be great for requirements that have a set amount of rows in the grid and the users shouldn't be able to add anymore rows to the grid.