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

[Solved] Disabled DropDownList column - Behavior Change in 2011 Q2

2 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.
Leo
Top achievements
Rank 1
Leo asked on 17 Jul 2011, 09:48 PM
Telerik,

  I have an MVC Grid with a special requirement: Allow to insert rows, but only allow certain fields to be updated. I was achieving this by manually disabling specific DropDownLists using onGridEdit client-side event... After updating to 2011.2.712.340 I notice that the disabled field values are no longer included in the form post values...

 Is this the expected behavior? Is there a workaround I could try to accomplish this?

Thanks,
Leo.

2 Answers, 1 is accepted

Sort by
0
Henry
Top achievements
Rank 1
answered on 18 Jul 2011, 03:04 AM
I was using server edit mode, I had same requirement, the following are my solution for your reference:

Add an editor template file for editable object:

@model WorkflowAction
 
<table>
<tr>
    <td>@Html.LabelFor(model => model.ActionName)</td>
    <td>@Html.EditorFor(model => model.ActionName) @Html.ValidationMessageFor(model => model.ActionName)</td>
</tr>
<tr>
    <td>@Html.LabelFor(model => model.ActionDesc)</td>
    <td>@Html.EditorFor(model => model.ActionDesc) @Html.ValidationMessageFor(model => model.ActionDesc)</td>
</tr>
@if (Request.QueryString["Grid-mode"].ToLower() == "insert")
{
<tr>
    <td>@Html.LabelFor(model => model.WorkflowTypeId)</td>
    <td>@Html.EditorFor(model => model.WorkflowTypeId) @Html.ValidationMessageFor(model => model.WorkflowTypeId)</td>
</tr>
<tr>
    <td>@Html.LabelFor(model => model.OldStatus)</td>
    <td>@Html.EditorFor(model => model.OldStatus) @Html.ValidationMessageFor(model => model.OldStatus)</td>
</tr>
<tr>
    <td>@Html.LabelFor(model => model.NewStatus)</td>
    <td>@Html.EditorFor(model => model.NewStatus) @Html.ValidationMessageFor(model => model.NewStatus)</td>
</tr>   
}
else
{
  // You can place hidden object here for post back.
  // @Html.HiddenFor(......)
}
<tr>
    <td>@Html.LabelFor(model => model.IsNotifiable)</td>
    <td>@Html.EditorFor(model => model.IsNotifiable) @Html.ValidationMessageFor(model => model.IsNotifiable)</td>
</tr>
<tr>
    <td>@Html.LabelFor(model => model.IsAvailable)</td>
    <td>@Html.EditorFor(model => model.IsAvailable) @Html.ValidationMessageFor(model => model.IsAvailable)</td>
</tr>
<tr>
    <td style="width:200px"> </td>
    <td> </td>
</tr>
</table>
0
Dimo
Telerik team
answered on 18 Jul 2011, 07:10 AM
Hello,

Disabled form elements do not submit their values, so for Q2 2011 we changed the behavior of some of our components to match this, as mentioned in the release notes.

The workaround in this case depends on the developer's preferences - for example the component can be hidden with Javascript, but not disabled.

Regards,
Dimo
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
Leo
Top achievements
Rank 1
Answers by
Henry
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or