Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>UPDATE</strong>:</p> <p>To prevent unnecessary downvotes for a 4-year-old answer, I am including the question @ataravati provided in the comments below. Go here for a better and more modern answer: <a href="https://stackoverflow.com/questions/14321396/kendo-ui-grid-different-templates-for-edit-and-create">Kendo UI grid - different templates for Edit and Create</a></p> <p><strong>OLD ANSWER</strong>:</p> <p>This isn't a C# answer, but it is relevant. I use the JavaScript API and managed to figure out a way to differentiate between "Add" and "Edit", and have the popup editor react differently for each. My reasoning was that when Adding a new entry, all fields would be editable, but when Editing an existing entry, I needed to make some fields read-only.</p> <p>In a nutshell, I add a jQuery click listener for the toolbar buttons and use a set of if statements to determine whether the clicked button has a class of <code>k-grid-edit</code> or <code>k-grid-add</code> (or custom classes if I'm using custom-defined toolbar buttons in my Grid widget). Then, I store the action type ("Add" or "Edit") in a data-attribute on the parent Grid:</p> <p><code>$("#grid").data("action","add");</code></p> <p>...which I then read within the custom popup editor template to determine whether certain fields should be read-only or not:</p> <p><code>if ($("#grid").data("action") === "add") { /*Do stuff*/ }</code></p> <p>I also use this method to hide or show toolbar buttons depending upon the situation (for example, in Inline Editor mode, The Save and Cancel buttons should only be visible while a row is in Edit Mode, so when the user selects a row in the Grid and clicks the Edit button, the hidden-by-default Save and Cancel buttons are shown, and the other buttons are hidden. Once the Edit action is completed and the user clicks on Save or Cancel, then the buttons switch back to their initial states).</p> <p>For more explicit information, here's my Kendo UI forum thread on the topic:</p> <p><a href="http://www.kendoui.com/forums/ui/grid/kendo-grid---how-to-have-different-custom-editor-for-update-and-create.aspx" rel="nofollow noreferrer">http://www.kendoui.com/forums/ui/grid/kendo-grid---how-to-have-different-custom-editor-for-update-and-create.aspx</a></p> <p>I posted some sample code, and another user named Philipp came up with a different solution that arrives at the same end result and posted his code as well.</p> <p><strong>So, to answer your question:</strong></p> <p>No. There is no simple way. The functionality is not currently included in the Kendo UI framework. It is, however, still possible with a bit of extra elbow grease. Or caffeine. :)</p> <p>I hope this is helpful.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload