Thanks,
Vaishali
6 Answers, 1 is accepted
I am not sure I clearly understand your questions. You want to update the model item for that particular row in the dataSource when you change the selection of the Radio button? What exactly do you mean by "send the model object to controller on external Submit button action" ?
Kind regards,
Petur Subev
the Telerik team
You are right, I want to update the model item for that particular row in the dataSource when you change the selection of the Radio button?
So the view is strongly typed with one of the complex object, which provides datasource to render the grid. I have Submit Button at the end of the page, when user clicks on submit I want to send the complex object back to controller including user's radio button selection.
But the object is null when it comes back to controller.
here is the code -
<% Html.Telerik().Grid(Model.idrequest)
.Name("IdRequest")
.DataKeys(dataKeys =>
{ dataKeys.Add(r => r.RequestDetailsId).RouteKey(
"RequestDetailsId");
}
)
.Columns(columns =>
{
columns.Bound(r => r.RequestDetailsId);
columns.Bound(r => r.EmpId);
columns.Bound(r => r.Name);
columns.Bound(r => r.Email);
columns.Bound(r => r.ADSId);
columns.Bound(r => r.Action);
columns.Bound(r => r.Role);
if (columns.Bound(r => r.Action).Equals("Suspend"))
{
columns.Bound(r => r.SuspensionDate).Format(
"{0:MM/dd/yyyy}").Width(100);
columns.Bound(r => r.SuspensionReason);
}
if (Model.idrequest[0].Action == "Reactivate")
columns.Bound(r => r.ReactivationDate).Format(
"{0:MM/dd/yyyy}").Width(100);
if (Model.idrequest[0].Action == "Delegate")
{
columns.Bound(r => r.DelegateOwner);
columns.Bound(r => r.DelegationStartDate).Format(
"{0:MM/dd/yyyy}").Width(100);
columns.Bound(r => r.DelegationEndDate).Format(
"{0:MM/dd/yyyy}").Width(100);
}
columns.Template(r =>
{
%>
<%
= Html.RadioButton(r.RequestDetailsId.ToString(), "true", false, new { @id = "yes_Approve", @group = "Approval", @class="Radio" })%><label for="yes_Approve">Approve</label>
<%
= Html.RadioButton(r.RequestDetailsId.ToString(), "false", false, new { @id = "no_Approve", @group = "Approval", @class = "Radio" })%><label for="no_Approve">Deny</label>
<%
}).Title(
"Approve");
columns.Template(r =>
{
%>
<%
= Html.Hidden("Approved", new { @id = "hfApprove", @class="hfA" })%>
<%
= Html.Hidden("RequestDetailsId", new { @id = "hfRDetailsId", @class="hfRD" })%>
<%
}).Hidden();
})
.Pageable(paging => paging.Enabled(
true).PageSize(10))
.KeyboardNavigation()
.Filterable(filtering => filtering.Enabled(
true))
.Sortable(sorting => sorting.Enabled(
true))
.Groupable(grouping => grouping.Enabled(
true))
.Resizable(resizing => resizing.Columns(
true))
.Render();
%>
<%
=Html.Telerik().ScriptRegistrar().OnDocumentReady(
"$('" + ".Radio').click(function check(){ var Index =$(this).closest('"+"tr'"+").prevAll('"+"tr'"+").length; alert(Index);"+
"var grid = $('" + "#IdRequest'" + "); var row = grid.children().children(1)[2].children[Index];" +
"if(this.id=='" + "yes_Approve'" + "){ $(row).find('" + "#Approved'" + ").val(true); $(row).find('" + "#RequestDetailsId'" + ").val(this.name);}" +
"else{ $(row).find('" + "#Approved'" + ").val(false); $(row).find('" + "#RequestDetailsId'" + ").val(this.name);}" +
"}); "
) %>
</div>
<div class="content">
<input type="submit" id="approveRequest" value="Submit" />
</div>I am afraid that your question is not directly related to the Grid component but how to submit list of groups of radio buttons to a MVC controller action. Here are some links which you might need when dealing with the submit of a collection.
http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx
http://weblogs.asp.net/nmarun/archive/2010/03/13/asp-net-mvc-2-model-binding-for-a-collection.aspx
Kind Regards,
Petur Subev
the Telerik team
The use of inappropriate or offensive language is not permitted on our site. Insulting, threatening, and harassing comments will not be tolerated.
The use of inappropriate or offensive language is not permitted on our site. Insulting, threatening, and harassing comments will not be tolerated.
Please refrain from using offensive language in your postings.
Georgi Tunev
Technical Support Director
Telerik