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

[Solved] Grid custom editor template pass in a value from another field on each row

1 Answer 173 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.
Kriya
Top achievements
Rank 1
Kriya asked on 30 May 2012, 09:58 PM
I am using an ajax bound dropdownlist in edit mode for the grid, I need the dropdownlist to be based on the selected value from another dropdownlist on the same row in the grid. How can that be done?

View
@(
Html.Telerik().Grid(Model)
.Name("Round")
.DataKeys(keys => keys.Add(o => o.Id)
.RouteKey("Id"))
.ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image).ImageHtmlAttributes(new { style = "margin-left:0" }))
.DataBinding(dataBinding => dataBinding.Server()
.Insert("Rounds_update", "Round")
.Update("Rounds_update", "Round")
.Delete("Rounds_delete", "Round"))
.PrefixUrlParameters(false)
.Columns(columns =>
{
    columns.Bound(o => o.RoundNo).Width(120);
    columns.ForeignKey(o => o.GameType, (IEnumerable)ViewData["gameType"], "Key", "value").Width(120);
      // the bound column below is the one i need the value from for the other dropdown list
    columns.Bound(o => o.Course).Width(180);
    columns.Bound(o => o.Date).Width(180);
    columns.Bound(o => o.NoInFlight).Width(120).EditorViewData(new { delaultVal = 5 });
    columns.Bound(o => o.StartTime).Width(140);
     
 
    columns.Bound(o => o.Interval).Width(170);
    columns.Bound(o => o.HoleNo).Width(120);
     
   // bound field for which I have the custom editorTemplate
    columns.Bound(o => o.DefaultTeeboxIdMen);
    columns.Bound(o => o.DefaultTeeboxIdWomen);
     
    columns.Command(commands =>
    {
        commands.Edit().ButtonType(GridButtonType.Image);
        commands.Delete().ButtonType(GridButtonType.Image);
    });
})

Editor Template
<%@ Control Language="C#" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewUserControl<int>" %>
<%@ Import Namespace="Telerik.Web.Mvc.UI" %>
 
<%= Html.Telerik().DropDownListFor(m => m)
.Name("DefaultTeeboxIdMen")
.BindTo(new SelectList((IEnumerable)ViewData[ShowMe.Tournament.Administration.Helpers.WizardHelper.TeeMen], "HoleId", "Name"))
.DataBinding(bind => bind.Ajax().Select("Ajax_teeboxList", "Ajax")) %>

Controller method
public ActionResult Ajax_teeboxList(int? id)
{
            var content = Lists.TeeboxList(id);
            return new JsonResult { Data = new SelectList(content, "HoleId", "Name") };
}

Could the value somehow be sent to the editortemplate and from there be sent into  the parameter through the ajax call?

1 Answer, 1 is accepted

Sort by
0
Sanjaykumar
Top achievements
Rank 1
answered on 10 Mar 2013, 01:36 AM
Hello,

I am having the same requirement...Did you find the solution? Can you please provide me the solution if you have found it?

Thanks a lot in advance!

Regards,
Sanjay Patel
Tags
Grid
Asked by
Kriya
Top achievements
Rank 1
Answers by
Sanjaykumar
Top achievements
Rank 1
Share this question
or