Editing custom editor - Not working in PopUp Mode & Dynamic

12 posts, 0 answers
  1. Meypar
    Meypar avatar
    10 posts
    Member since:
    May 2019

    Posted 09 Jan 2020 Link to this post

    Hello,

    I'm trying to built a reusable grid component with Kendo Grid (ASP.NET Core) but I'm finding some problems with its configuration.

    Taking the example, https://demos.telerik.com/aspnet-core/grid/editing-custom, if we configure edition mode as PopUp, the result form doesn't show the custom field. 

    Same happens if we change the grid type Grid<Kendo.Mvc.Examples.Models.ProductViewModel>() -> Grid<dynamic>(). In this case to configure fields I use the overload with (Type memberType, string memberName) params.

    Do I need to configure something else?

    One solution is to use the Foreign configuration, like this https://demos.telerik.com/aspnet-core/grid/foreignkeycolumn, but with grid type dynamic (Grid<dynamic>())  grid disappears and no errors are shown.

     

    What I need would be the edition mode to be PopUp and the grid type dynamic. How can I do that?

    Thank you.

    Best Regards,

    Ivan

  2. Georgi
    Admin
    Georgi avatar
    700 posts

    Posted 14 Jan 2020 Link to this post

    Hi Ivan,

    When in popup edit mode, the custom editor represents the whole content of the popup. You can find a sample which demonstrates how to create a custom popup editor in our examples repository:

    Regards,
    Georgi
    Progress Telerik

    Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
  3. Meypar
    Meypar avatar
    10 posts
    Member since:
    May 2019

    Posted 15 Jan 2020 in reply to Georgi Link to this post

    Hi Georgi,

    Thank you for your answer, that's very clear.

    What I'm looking for is a little more complicated.

    I need to know how to show a dropdownlist in a popup (popup generated automaticaly by grid like this example https://demos.telerik.com/aspnet-core/grid/editing-popup) with ForeignKey column (like this https://demos.telerik.com/aspnet-core/grid/foreignkeycolumn) on a grid with model dynamic (@(Html.Kendo().Grid<dynamic>())

    Thank you.
    Best Regards,
    Ivan

     

  4. Georgi
    Admin
    Georgi avatar
    700 posts

    Posted 20 Jan 2020 Link to this post

    Hello Ivan,

    Generally speaking, the grid will use a drop down editor for all foreign key columns by default. However, you have to create a view named GridForeignKey.cshtml in the ~Views\Shared\EditorTemplates folder with the following content:

    @model object
    @(Html.Kendo().DropDownListFor(m => m)
        .BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
    )

    Do you have the editor configured as described above? If you do not, could you please add it and let me know if the drop down is generated?

    Regards,
    Georgi
    Progress Telerik

    Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
  5. Meypar
    Meypar avatar
    10 posts
    Member since:
    May 2019

    Posted 21 Jan 2020 in reply to Georgi Link to this post

    Hi Georgi,

    Yes, I have the editor created, as you described. Also I have included the [UIHint("GridForeignKey")] attribute to property, but It is still not working.

    Regards,

    Ivan

  6. Georgi
    Admin
    Georgi avatar
    700 posts

    Posted 23 Jan 2020 Link to this post

    Hi Meypar,

    Are you able to replicate the behavior in the sample from our examples repository?

    If not, would it be possible to send me a sample where the issue can be observed so I can debug it locally?

    Regards,
    Georgi
    Progress Telerik

    Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
  7. Meypar
    Meypar avatar
    10 posts
    Member since:
    May 2019

    Posted 24 Jan 2020 in reply to Georgi Link to this post

    Good morning Georgi,

    Sure, these are some changes:

    1. Take this example (https://demos.telerik.com/aspnet-core/grid/editing-custom) and change GridEditMode.InCell for this GridEditMode.PopUp. You will see Category field appears without dropdownlist. Same happen with my example Grid_Dynamic_PopUp_Custom.

    2. In the example Grid_Dynamic_PopUp_ForeignKey grid disapears from screen. If I change dynamic grid for a model grid (Grid_ByModel_PopUp_ForeignKey) works fine, but this is not what I need.

    My examples are in this url: https://we.tl/t-1Ko763BSo9

    Regards,

    Ivan
  8. Georgi
    Admin
    Georgi avatar
    700 posts

    Posted 29 Jan 2020 Link to this post

    Hello Meypar,

    You are correct, the grid from our demo will not render the drop down as there is a ProductViewModel editor specified within the EditorTemplates folder with the following content:

    <div class="product-view k-widget">
        <div class="edit-buttons">
            <a class="k-button k-button-icontext k-update-button" href="\\#"><span class="k-icon k-i-check"></span></a>
            <a class="k-button k-button-icontext k-cancel-button" href="\\#"><span class="k-icon k-i-cancel"></span></a>
        </div>
        <dl>
            <dt>Product Name</dt>
            <dd>
                @(Html.EditorFor(p => p.ProductName))
                <span data-for="ProductName" class="k-invalid-msg"></span>
            </dd>
            <dt>Unit Price</dt>
            <dd>
                @(Html.EditorFor(p => p.UnitPrice))
                <span data-for="UnitPrice" class="k-invalid-msg"></span>
            </dd>
            <dt>Units In Stock</dt>
            <dd>
                @(Html.EditorFor(p => p.UnitsInStock))
                <span data-for="UnitsInStock" class="k-invalid-msg"></span>
            </dd>
            <dt>Discontinued</dt>
            <dd>@(Html.EditorFor(p => p.Discontinued))</dd>
    
        </dl>
    </div>
    

    However, if you include a drop down within the above template, the grid will display it.

    e.g.

    @model Kendo.Mvc.Examples.Models.ProductViewModel
    
    <div class="product-view k-widget">
        <div class="edit-buttons">
            <a class="k-button k-button-icontext k-update-button" href="\\#"><span class="k-icon k-i-check"></span></a>
            <a class="k-button k-button-icontext k-cancel-button" href="\\#"><span class="k-icon k-i-cancel"></span></a>
        </div>
        <dl>
            <dt>Product Name</dt>
            <dd>
                @(Html.EditorFor(p => p.ProductName))
                <span data-for="ProductName" class="k-invalid-msg"></span>
            </dd>
            <dt>Unit Price</dt>
            <dd>
                @(Html.EditorFor(p => p.UnitPrice))
                <span data-for="UnitPrice" class="k-invalid-msg"></span>
            </dd>
            <dt>Units In Stock</dt>
            <dd>
                @(Html.EditorFor(p => p.UnitsInStock))
                <span data-for="UnitsInStock" class="k-invalid-msg"></span>
            </dd>
            <dt>Discontinued</dt>
            <dd>@(Html.EditorFor(p => p.Discontinued))</dd>
    
            <dt>Category</dt>
            <dd>
                @(Html.Kendo().DropDownListFor(m => m.CategoryID)
        .BindTo(new List<string>())
                )
            </dd>
        </dl>
    </div>

    If the grid disappears, it probably means that an error occurs during the compilation of the view. Please make sure that you do not use any htmlFor helpers when using dynamic as this would cause an error.

    Regards,
    Georgi
    Progress Telerik

    Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
  9. Meypar
    Meypar avatar
    10 posts
    Member since:
    May 2019

    Posted 30 Jan 2020 in reply to Georgi Link to this post

    Hello Georgi,

    Thank you for your examples, I used it in other approaches, but in this case I need something different.

    First of all, your code is from this example https://demos.telerik.com/aspnet-core/grid/editing-popup and the template is manually generated (I would have to create a new file with that code in the EditorTemplates folder). 

    I have only 1 file with my @(Html.Kendo().Grid<dynamic>()...) and I use it as ViewComponent in several views, therefore I can not create 1 file for each view.

    What I need is for the dynamic grid to build automatically a popup editor with column type ForeignKey as dropdown like this example https://demos.telerik.com/aspnet-core/grid/foreignkeycolumn but in PopUp Mode.

    How can I do that?

    Kind Regards,

    Ivan

  10. Georgi
    Admin
    Georgi avatar
    700 posts

    Posted 04 Feb 2020 Link to this post

    Hello Meypar,

    Have in mind that C# is strongly typed and we depend on the type of the model to generate the editor. Basically the convention in MVC is to set the editor of certain type to match the name of the type. Using dynamic is a bit of an edge case which has its limitations and the editors is one of them as we are not able to determine which editor should edit the current field without knowing its type.

    At this point I could suggest you to switch to jQuery configuration where editor are generated on the client, thus, types are not mandatory. Is that an option for you?

    Regards,
    Georgi
    Progress Telerik

    Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
  11. Meypar
    Meypar avatar
    10 posts
    Member since:
    May 2019

    Posted 05 Feb 2020 in reply to Georgi Link to this post

    Hello Georgi,

    I understand what are you saying.

    I thought configuring the grid column with overload "public virtual GridBoundColumnBuilder<TModel> Bound(Type memberType, string memberName)" would fix that limitation because column has the memberType info. Maybe this could be a new feature for your next version?

     

    I will try to switch to jQuery grid.

    Kind Regards,
    Ivan

  12. Georgi
    Admin
    Georgi avatar
    700 posts

    Posted 10 Feb 2020 Link to this post

    Hi Meypar,

    I can suggest you  to submit a feature request in our feedback portal and based on the traction it gains, we will consider implementing it.

    Regards,
    Georgi
    Progress Telerik

    Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
Back to Top