I like the answer @jfl gives, and it's useful to take that idea and extend it to a nice, reusable setup.
Why? There's a brittleness to keeping track of what the ordinal of the column is that you need to hide. That is, @jfl's answer only works for the first fieldset/column, and even the version in my quick comment requires that the order and potentially number of columns doesn't change.
Instead, you can standardize how you hide columns by placing a property in the columns' declaration, and then check for it in the edit
event handler that is invoked after the popup is displayed. You get a reference to the full columns
declaration in the edit
event, so we've got a lot of flexibility.
I've got a full example at this fiddle, but here it is in brief:
I've added a hideMe
property in the column declarations:
columns: [
{ field: "name" },
{ field: "position" },
{
field: "age",
hideMe: true // <<< This is new.
},
{ command: "edit" }
],
Then, building on the answer & comment mentioned earlier, I have this in my edit
handler:
e.sender.columns.forEach(function (element, index /*, array */) {
if (element.hideMe) {
e.container.find(".k-edit-label:eq(" + index + "), "
+ ".k-edit-field:eq( " + index + ")"
).hide();
}
});
No more column ordinal tracking needed. You can add columns, change orders, hide new ones, whatever just by changing what has hideMe
on it. (Looking back, I probably should've called that hideMeOnEdit
, but you get the point.)