This is a migrated thread and some comments may be shown as answers.
Disabling editing by column in a grid?
3 Answers 64 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
andrew
Top achievements
Rank 1
andrew asked on 23 Nov 2010, 09:03 PM
In a Grid control, how can I select which columns I want to disable for editing?

3 Answers, 1 is accepted

Sort by
0
andrew
Top achievements
Rank 1
answered on 25 Nov 2010, 07:16 PM
Nevermind. The [ReadOnly(true)] needs to be set.

For example:
namespace Telerik.Web.Mvc.Examples.Models
{
    using System;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    public class ClientEditableOrder
    {
        [ReadOnly(true)]
        public int OrderID { get; set; }
        [UIHint("ClientEmployee"), Required]
        public string Employee { get; set; }
        [DataType(DataType.Date), Required]
        public DateTime OrderDate { get; set; }
        [DataType(DataType.Currency), Required]
        public decimal Freight { get; set; }
    }
}

0
alonav
Top achievements
Rank 1
answered on 23 May 2011, 01:15 PM
Hi,
ReadOnly is not working when using GridEditMode.PopUp for editing.
I tried it in both ways:
I put the attribute above the field "[ReadOnly(true)]"
I also tried to put ReadOnly in the columns bound:

@(Html.Telerik().Grid(Model)

.Name(

 

"Grid")

 

 

.ClientEvents(events => events.OnLoad(

 

"onGridLoad"))

 

 

.DataKeys(keys => { keys.Add(d => d.ID); })

 

.Columns(columns =>

 

{

 

columns.Command(commands =>

 

{

 

commands.Edit().ButtonType(

 

GridButtonType.Image);

 

 

}).Width(60).Title(

 

" ");

 

 

columns.Bound(d => d.ID).Width(100).ReadOnly(

 

true);

 

 

columns.Bound(d => d.SoftwareVersion).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.IMEI).Width(100);

 

columns.Bound(d => d.RegistrationTime).Format(

 

"{0:MM/dd/yyyy}").Width(100);

 

 

 

 

})

 

.DataBinding(dataBinding => dataBinding.Ajax()

 

.Select(

 

"_AjaxParametersGrid", "Activities")

 

 

.Update(

 

"_SaveParametersEditing", "Grid"))

 

 

.Editable(editing => editing.Mode(mode))

 

.Pageable(paging => paging.Total((

 

int)ViewData["total"]))

 

 

.EnableCustomBinding(

 

true)

 

 

.Sortable()

 

.Scrollable(scrolling => scrolling.Height(390))

 

)


The inline editing is working fine but not good for me.

Please help
Alon
0
Atanas Korchev
Telerik team
answered on 24 May 2011, 08:02 AM
Hi alonav,

 You can check this entry from the grid troubleshooting help article.

Greetings,
Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
andrew
Top achievements
Rank 1
Answers by
andrew
Top achievements
Rank 1
alonav
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or