Hi,
I have a case where I need one column to be always editable as shown in this screenshot:
This was written a long time ago before anyone here was using the telerik grid. Now that I have everything populated nicely I am trying to get the status column to be always accessible for quick setting of the status and at the same time I want an edit button to edit the larger model in an Editor Template or open a partial view. I did my best to google this and the ai generated answer doesn't work. I'm getting conflicting advice on whether or not I should use the Editable property on the column bound vs. in the datasource. I like to take things in small steps so my first task was getting the three other columns readonly. I did this through the datasource because .Editable(false) or .Editable("false') on column bound did not work. I found out that one is the older way of doing this. I can't remember which is which. Anyway below is what the example said to do and it doesn't work unless I press the edit button. I did this inline for now but I will be doing the popup of some type.
GRID DEFINITION
@(
Html.Kendo().Grid<HookupChargeViewModel>()
.Name("HookupChargesList")
.Columns(columns =>
{
columns.Bound(p => p.Id).Hidden(true);
columns.Bound(p => p.PropertyOwner).Title("Property Owner");
columns.Bound(p => p.AddressDisplay).Title("Address");
columns.Bound(p => p.TaxAccountDisplay).Title("Tax Account");
columns.ForeignKey(p => p.HookupChargeStatusID, (System.Collections.IEnumerable)ViewData["LookupHookupChargeStatuses"], "IdNumber", "Name").Title("Status").Editable("alwaysEditable");
columns.Command(command => { command.Edit(); }).Width(220);
})
.ToolBar(toolbar => { toolbar.Create().Text("Add New Hookup Charge Worksheet"); })
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Sortable()
.Scrollable()
.Filterable(filterable => filterable.Extra(false))
.Pageable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.ServerOperation(false)
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.PropertyOwner);
model.Field(p => p.AddressDisplay).Editable(false);
model.Field(p => p.TaxAccountDisplay).Editable(false);
model.Field(p => p.HookupChargeStatusID);
})
.Read(read => read.Action("HookupCharges_Read", "HookupCharges"))
.Create(create => create.Action("HookupCharges_Create", "HookupCharges"))
.Update(update => update.Action("HookupCharges_Update", "HookupCharges"))
)
.Events(events => events.Edit("grid_edit"))
)
SCRIPT
<script>
function alwaysEditable(dataItem) {
return true; // Always allow editing for this column
}
</script>