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

[Solved] Hidden values on grid

2 Answers 190 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.
Tiago
Top achievements
Rank 1
Tiago asked on 12 Oct 2010, 06:33 PM
Hi there.

First of all, i would like to congratulate telerik team for the great work put into MVC controls.

But, we have the following question regarding grid and hidden fields on it:

1) On update scenario, we must add hidden values to be passed to controller's action. We must have it for validation proposes.
We're trying to use the BoundColumn.Hidden() method to hide what we want and pass it to controller's on POST. The problem is that none of the values are getting into the controller's action. (we double checked it using fiddler proxy).

2) On Insert scenario, we want to initialize this hidden values as well for the same motive, i.e., validation.

We're using server binding, and the code is this:

<%
Html.Telerik().Grid(Model.Details)
.Name("Grid")
.DataKeys(keys => keys.Add(c => c.Id))
.ToolBar(commands => commands
.Insert().ButtonType(GridButtonType.Text))
.DataBinding(dataBinding => dataBinding.Server()
.Insert("CreateDetail", "ExchangeRates", new { mode = GridEditMode.InLine, type = GridButtonType.Text })
.Update("EditDetail", "ExchangeRates", new { mode = GridEditMode.InLine, type = GridButtonType.Text })
)
.Columns(columns =>
{
columns.Bound(p => p.Value).Width(120).Title(Resources.Value);
columns.Bound(p => p.StartDate).Width(120);
columns.Bound(p => p.EndDate).Width(120);
columns.Bound(p => p.ExchangeRateLastStartDate).Hidden();
columns.Command(commands =>
{
commands.Edit().ButtonType(GridButtonType.Text);
}).Title(Resources.Action);
})
 
.Pageable(paging => paging.PageSize(8))
.Render();
%>

Basically we want to keep the value of the property ExchangeRateLastStartDate stored between post backs, and initialize it when  adding a new record.

This is the right approach for doing it?

Thanks in advance for your help.

With kindest regards.

Tiago

2 Answers, 1 is accepted

Sort by
0
Tiago
Top achievements
Rank 1
answered on 13 Oct 2010, 05:42 PM
Hi there onde again.

Anyone has passed by this issue?

Or maybee can point some other way of doing it, please.

Best regards.

Tiago
0
Atanas Korchev
Telerik team
answered on 14 Oct 2010, 07:47 AM
Hi Tiago,

 I am sending you a sample project showing how to have a hidden field during editing. I am not sure how the insert should work though - perhaps you can use a default value for that hidden property when doing inserts.

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
Tags
Grid
Asked by
Tiago
Top achievements
Rank 1
Answers by
Tiago
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or