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

Popup Edit Mode hide ID column

2 Answers 1756 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 17 Jul 2015, 11:43 AM

Hi,

 

I have table which contains an ID column (Identity) and several other fields.

If I use "Inline" I can edit and add records.

The ID column is (as intended) not visible.

But a soon as I change to "Popup" the ID column shows up as edit field.
I changed the field to readonly via model.Field(p => p.​ID).Editable(false);
Still I have an edit field for the ID - and I can change the value (although this is not persisitet to the DB).

So how to hide the column in Popup edit mode.

Manfred

2 Answers, 1 is accepted

Sort by
2
ManniAT
Top achievements
Rank 2
answered on 20 Jul 2015, 12:09 PM

Hi,

 I could fix this adding "[ScaffoldColumn(false)]" to the column in my datamodel.

Kapil
Top achievements
Rank 1
commented on 10 Aug 2021, 05:10 AM

 public class studentdata
    {
        [ScaffoldColumn(false)]
        public int Id { get; set; }

        public string Name { get; set; }
    }

this will hide an id in the popup. 

 

Anton Mironov
Telerik team
commented on 11 Aug 2021, 01:15 PM

Hi Kapil,

Thank you for sharing the code snippet with the community.

If any assistance from the team is needed, do not hesitate to contact us.

Kind Regards,
Anton Mironov
0
Alexander Popov
Telerik team
answered on 21 Jul 2015, 08:42 AM
Hi ManniAT,

Indeed that is the recommended approach. Alternatively, you could specify an entirely custom Editor Template, as shown here.

Regards,
Alexander Popov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Salma
Top achievements
Rank 1
Iron
commented on 28 Nov 2021, 12:12 AM

That is kind of old but I have the same issue.  I am using MVC.net (not core)

The recommended resoution is working but it hides the column from the main grid.

        [ScaffoldColumn(false)]
        public int Id { get; set; }

I want to show the column "Date Entetred' on the grid but I want to hide it when user editing the row or when user saving a new data.  

Similarly, I want to make a read only field when user is editing or saving.  For example, I want to show the grid with the UserId,

but i do not want to make it readonly.  I used the below code but it is not working for popup.  

I used to disable the field model.Field(p => p.​ID).Editable(false);

Eyup
Telerik team
commented on 30 Nov 2021, 11:37 AM

Hi Salma,

This requirement is possible using the following attribute:

[ReadOnly(true)]
Here you can find additional info:
https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.readonlyattribute?view=net-6.0

You can also check this resource:
https://stackoverflow.com/questions/20566539/readonly-attribute-in-mvc-4

Salma
Top achievements
Rank 1
Iron
commented on 30 Nov 2021, 01:35 PM

Hi ,

this did not work on the popup as well.

ReadOnly(true)

or

[Editable(false)]

These are good for inline editing but unfortunately not working for the popups 

Eyup
Telerik team
commented on 02 Dec 2021, 10:07 AM

In this case, you could use custom PopUp editing template and define the generated fields and elements manually, as demonstrated in this sample:
https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/custom-popup-editor
Tags
Grid
Asked by
ManniAT
Top achievements
Rank 2
Answers by
ManniAT
Top achievements
Rank 2
Alexander Popov
Telerik team
Share this question
or