Passing additional value to popup

6 posts, 1 answers
  1. Attila
    Attila avatar
    22 posts
    Member since:
    Oct 2016

    Posted 29 Sep 2017 Link to this post

    Hi! 

    Is it possible to pass additional data from my grid to the popup window beside the bound object?

    @(Html.Kendo().Grid<GazoraAllasModels>()
              .Name("grid")
              .Columns(columns =>
              {
                  columns.Bound(c => c.Oraallas).Title("Óraállás");
                  columns.Bound(c => c.LeolvasasDatum).Title("Leolvasás dátuma");
              })
              .Editable(e => e.Mode(GridEditMode.PopUp).TemplateName("AddOraallas").AdditionalViewData(new { maxOra = "=#MaxOra()#" }))

     

    I would like to pass data of a return value of javascript function as you can see (MaxOra()

    On the editable template cshtml file has @ViewData["maxOra"] but the value is the string of "=#MaxOra#" and not the value. The cshtml starts with these lines, so I cannot pass this value in model:

    @model MyProject.Models.MyProjectModels
    @using Kendo.Mvc.UI
    @ViewData["maxOra"]

    This value cannot be in the model class. I really need to pass it as additional data.

    Thanks

  2. Answer
    Stefan
    Admin
    Stefan avatar
    3008 posts

    Posted 03 Oct 2017 Link to this post

    Hello, Attila,

    Currently, the additional data can be passed only as static data.

    @{
        string customValue= "some value";
    }
     
    .AdditionalViewData(new {customValue= customValue})

    The other option will be to use the document ready event of the Custom template used for editing to execute a function which will be called every time the template is used:

    <script>
        $(document).ready(function () {
            var uid = $("#@ChildGridName").closest("[data-uid]").data("uid");
            var parentGrid = $("#@ViewData["GridName"]").data("kendoGrid");
            var model = parentGrid.dataSource.getByUid(uid);
            console.log(model)
        });
    </script>

    I hope this is helpful.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Zdzislaw Ziental
    Zdzislaw Ziental avatar
    30 posts
    Member since:
    Mar 2018

    Posted 11 Sep 2018 in reply to Stefan Link to this post

    Hi Stefan,

    I have the same problem but I can not solve it by your example.

    I need to get the ID of the record being used in the Edit Template.
    In this Template I'm using @Html.HiddenFor(b => b.UserID) but I also could not get the value for it.

    See part of my code:

     @(Html.Kendo().Grid<Site.Models.BullViewModel>()
        .Name("grid")
    .Editable(editable => editable.Mode(GridEditMode.PopUp)
            .DisplayDeleteConfirmation(false)
            .TemplateName("BullEdit").Window(w => w.Title("Bull")))

  4. Stefan
    Admin
    Stefan avatar
    3008 posts

    Posted 12 Sep 2018 Link to this post

    Hello, Zdzislaw,

    The UserID value should be available directly inside the template.

    Please refer to the following project demonstrating how to set up the editors inside the template when a custom popup editor is used inside the Grid:

    https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/custom-popup-editor

    If the issue still occurs please provide an example reproducing it as this will allow providing a suggestion best suited for it.

    Regards,
    Stefan
    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.
  5. Zdzislaw Ziental
    Zdzislaw Ziental avatar
    30 posts
    Member since:
    Mar 2018

    Posted 12 Sep 2018 in reply to Stefan Link to this post

    Hi Stefan,

     

    I'll try to explain the situation in more detail.

    I have a grid that is a list of bulls, when the bull is clicked, a popup with the bull data opens.

    So far so good, bull data is being sent to "EditorTemplates" without any problems. All controls are populated with model data.

    This popup has the control "Html.Kendo (). TabStrip ()", in tab 1 are all the data of the model, and in tab 2 it must be populated with data that is not in this model.

    My idea is to populate these other data using jquery, and when the user is "saving" the changes I save these two types of data separately.
     The problem is that I am not able to "get" the UserID that is used in a hidden control, as shown below.
    @Html.HiddenFor (b => b.UserID)

    This object is created with the name "UserID";

    But when I try to "catch" this value, it is always null.

    Any suggestions on how to solve this situation or how to "read" the value of this control?

  6. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 14 Sep 2018 Link to this post

    Hello,

    Could you please elaborate if the UserID is part of the Grid model, because if it is part from the edited dataItem, its value should be set to the hidden input element when the editor template is bound?

    If the issue persists you could open support ticket and attach a runnable project demonstrating the scenario and the issue, so we can test and debug it locally.


    Regards,
    Konstantin Dikov
    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.
Back to Top