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

Ajax Grid filtered by DropDownList needs data passed to EditorTemplate

6 Answers 162 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 05 Jun 2014, 04:26 PM
Hello,

I've got an ajax bound grid that is loading based on the chosen option in a dropdownlist.  I would like to pass the value of the dropdownlist along with another model parameter (the ID of the row) to the EditorTemplate but I can't seem to do this.  I tried adding the IDas a Field so it would be bound to a hidden in the EditorTemplate but this doesn't seem to be working.  Also not sure how to get the dropdownlist passed in to the EditorTemplate.  I know how to do it for the Read method but it didn't work the same for the Create.

Here is the View:

@{
    ViewBag.Title = "PRP Members";
}
 
<h2>PRP Members</h2>
 
@Html.Partial("_LastViewedUserFacility")
 
<div class="filter">
    <label class="filter-label" for="filter">Filter:</label
    @(Html.Kendo().DropDownList()
        .Name("Filter")
        .DataTextField("Code")
        .DataValueField("ID")
        .Events(e => e.Change("onChange"))
        .BindTo((System.Collections.IEnumerable)ViewData["PRPs"])
    )
</div>
 
<br class="clear" />
<br />
 
@(Html.Kendo().Grid<PASSAdmin.ViewModels.UserFacilityAdmin.PRPMemberViewModel>()
    .Name("PRPMembers")
    .Columns(columns =>
    {
        columns.Command(command => { command.Edit(); }).Width(90);       
        columns.Bound(c => c.First_Name).Title("First Name");
        columns.Bound(c => c.Last_Name).Title("Last Name");
        columns.Bound(c => c.Chair);
    })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("UserFacilityAdmin/PRPMember").Window(window => window.Width(400)))   
    .Sortable()
    .AutoBind(true)
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
        {
            model.Id(m => m.Pool_ID);
            model.Field(f => f.Pool_ID);
        })
        .Create(create => create.Action("AddPRPMember", "UserFacilityAdmin"))
        .Read(read => read.Action("GetPRPMembers", "UserFacilityAdmin").Data("additionalData"))
        .Update(update => update.Action("UpdatePRPMember", "UserFacilityAdmin"))
    )
)
 
<script type="text/javascript">
function additionalData(e) {
    var value = $('#Filter').data('kendoDropDownList').value();
    return { prpID: value };
}
function onChange() {
    $('#PRPMembers').data('kendoGrid').dataSource.page(1);
}
</script>

6 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 09 Jun 2014, 12:47 PM
Hello Stephen,

You mentioned that you want to send the Id of current row for a DropDownList widget which is inside the popup of a Grid. To demonstrate one way I prepared a small demo project:

If this is not what you are looking for could you please elaborate?

Kind Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Stephen
Top achievements
Rank 1
answered on 09 Jun 2014, 01:18 PM
Hi,

Thanks for the response but that's not exactly it.  The dropdown list is not part of the grid, it's just in the same view and it actually filters the grid.  I need the currently selected value of that dropdown list passed when I do an add.  

Then I also need one of the grid parameters passed to the add.  It's just one of the model parameter that's in the grid.
 
 I need to get this done rather quickly so can we move this over to a support ticket? Would that speed things up a little bit?

thanks,

Steve
0
Stephen
Top achievements
Rank 1
answered on 10 Jun 2014, 06:01 PM
I have created a support ticket for this question.
0
Petur Subev
Telerik team
answered on 11 Jun 2014, 08:14 AM
Hello Stephen,

I posted a reply in the support ticket that you opened on the same subject. Feel free to continue our conversation there.

Kind Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Shawn
Top achievements
Rank 1
answered on 31 Jul 2019, 01:03 PM

What is the answer to this.  I need the same thing?

 

thanks

0
Georgi
Telerik team
answered on 02 Aug 2019, 07:39 AM
Hi Shawn,

You could pass the additional value to the editor template through ViewData/ViewBag. Simply assign the value within the controller and then access it in the editor view.

I hope this helps.


Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Stephen
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Stephen
Top achievements
Rank 1
Shawn
Top achievements
Rank 1
Georgi
Telerik team
Share this question
or