This is a migrated thread and some comments may be shown as answers.

Unable to make a column(using a client template) read-only on edit

2 Answers 192 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Samyukta
Top achievements
Rank 1
Samyukta asked on 26 Jun 2018, 09:28 PM

Hi Team,

 

I have a grid with columns that has dropdownlists. I am using EditorTemplates for these dropdownlists. My concern is that I am unable to make these columns readonly on Edit. However, I am able to make the other non-dropdown columns to do the same behaviour and it works.

 

this is my column setup:

columns.Bound(a => a.Account).ClientTemplate("#=Account.AccountName#").Width(200); 

columns.Bound(a => a.dtEffectiveDate).Width(200);

 

this is my editor template:

@model GlobalCommissionAndAccountAssignments.Models.AccountUpdate.AccountModel
@{
    ViewBag.Title = "AccountsList";
}

@(Html.Kendo().DropDownListFor(m => m)
                                    .DataValueField("AccountId")
                                    .DataTextField("AccountName")
                                    .BindTo((System.Collections.IEnumerable)ViewData["accounts"])
)

 

My code t o make these columns as read-only on edit:

.Events(e => e.Edit("onGridEdit"))

<script>

    function onGridEdit(e) {
        if (e.model.isNew() == false) {
            $('input[name=dtEffectiveDate]').parent().html(e.model.dtEffectiveDate); ----> this works
            $('input[name=Account]').parent().html(e.model.Account); ----> this does not work (the one using a model and client template and editor template)
        }
    } 

</script>

Thank you in advance.

Sam

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 28 Jun 2018, 10:13 AM
Hello Sam,

If you would like to make Grid columns editable based on a specific condition I would recommend using the Editable option. Please check out the article below that illustrates the functionality. 


Give the approach a try and let me know how it works on your end.


Regards,
Viktor Tachev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Samyukta
Top achievements
Rank 1
answered on 29 Jun 2018, 06:28 PM
Thank you Viktor. It worked!
Tags
Grid
Asked by
Samyukta
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Samyukta
Top achievements
Rank 1
Share this question
or