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

[Solved] grid doesn't post model properties annotated as non editable(

3 Answers 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marcin
Top achievements
Rank 1
Marcin asked on 15 Jun 2011, 05:03 PM
Hi,

I've got a problem with ajax binding and updating the model which has properties annotated as non-editable. I've checked the http request on the client side and it not contains properties marked as non-editable.

EDIT:
The same effect is when I remove editable attribute and call a .ReadOnly() method on that column.

I'd by thankful for any advice.
(ver. 2011.1.414.340)

Here's my view snippet and controler's code:
 
    <p>
      <%= Html.Telerik().Grid<MvcApplication1.Controllers.HomeController.DataContainer>()
        .Name("Grid")
        .DataKeys(keys =>
        {
            keys.Add(p => p.Id);
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Select("_Select", "Home")
                .Update("_Update", "Home");
        })
        .Columns(columns =>
        {
            columns.Bound(p => p.TextData).Width(130);
            columns.Bound(p => p.NonEditableData).Width(130);
            columns.Command(commands =>
            {
                commands.Edit();
            }).Width(180).Title("Commands");
        })
        .Editable(editing => editing.Mode(Telerik.Web.Mvc.UI.GridEditMode.InLine))
        .Pageable()
        .Scrollable()
        .Sortable()
%>
    </p>
public class DataContainer
{
    public string TextData { get; set; }
    [Editable(false)]
    public string NonEditableData { get; set; }
    [ScaffoldColumn(true)]
    public int Id { get; set; }
}
 
[GridAction]
public ActionResult _Select()
{
    return View(new GridModel(GenerateData()));
}
[GridAction]
public ActionResult _Update()
{
    var data = new DataContainer();
 
    if(TryUpdateModel(data))
    {
        // here the model.NonEditableData is null
        return View();
    }
    return View();
}
 
 
public IEnumerable<DataContainer> GenerateData()
{
    return from n in Enumerable.Range(1, 100)
           select new DataContainer()
           {
               TextData = n.ToString(),
               NonEditableData = n.ToString(),
               Id = n
           };
}

3 Answers, 1 is accepted

Sort by
0
Marcin
Top achievements
Rank 1
answered on 16 Jun 2011, 09:59 AM
Hi,

I've checked the previous version of controls and there's the posted data contains value of all model's properties. I'm wondering if this is a feature or rather a bug.
0
Accepted
Atanas Korchev
Telerik team
answered on 16 Jun 2011, 10:01 AM
Hello Marcin,

 The grid posts only the editable properties in Inline, informs and popup editing mode. In InCell editing mode it posts all properties of the model. Indeed we released a version which behaved as InCell mode always but a lot of customers found that unexpected and breaking. Thus we decided to keep that behavior only in InCell mode.

Regards,
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
0
Marcin
Top achievements
Rank 1
answered on 16 Jun 2011, 11:20 AM
Thanks for reply, I'd have to take it into account in my application.
Best regards.
Tags
Grid
Asked by
Marcin
Top achievements
Rank 1
Answers by
Marcin
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or