Unplanned
Last Updated: 12 Mar 2024 15:17 by Joe
Ben Hayat
Created on: 15 May 2020 02:14
Category: Grid
Type: Feature Request
20
Show different columns in the popup edit form than are shown in the grid

ADMIN EDIT: Please review this thread and add your comments so we can get the community feedback on this. We have attached to this opener post a small sample that shows how to achieve this with a few lines of code, and a short video of that behavior.

Hello Team;

The Grid Popup is a great feature, but my understanding is that the Popup form ONLY shows properties that are assigned as columns to the Grid.
If true, this poses some restrictions for us. Many times we might show ONLY small # of columns in Grid, however the form requires MORE properties during ADD or UPDATE.
Is it possible that we can use two ViewModels, one for the Grid columns with less properties and one with more properties for ADD & UPDATE?

Note: If this FR is considered, perhaps we can have separate ViewModel for Update and ADD, as sometimes, ADD might require more properties to be added than later be updated.

This feature will save a lot of time to build apps that have many tables and we have to create CRUD operations

Attached Files:
17 comments
ADMIN
Dimo
Posted on: 27 Feb 2024 09:36

@Alex,

In addition to Width="0" for the column, you can:

        <GridColumn
                    Width="0"
                    OnCellRender="@( (GridCellRenderEventArgs args) => args.Class = "no-content" )">
            <Template></Template>
        </GridColumn>

<style>
    .no-content {
        font-size: 0 !important;
    }
</style>

Of course, a Grid popup FormTemplate is also an option, if you also need other customizations.

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
alex
Posted on: 26 Feb 2024 04:26

This would be a nice feature. 
Width set to 0 did not work for me as visible = false would. Visible = false would never render it whereas width=0 is. The height of the row still reflects the width0 field. For me I want to hide a large text field from the grid but allow editing in popup. 

 

SO my option was to try the dynamic visibility handler when editing or adding, but again the grid behind the popup showing this massive field is just not nice for the professionalism of the build.

I suppose our only solution would be to display custom form components for the add and edit command. 

Martin
Posted on: 13 Feb 2023 22:42

To "hide" the column in the grid, but make it show in the Popup Editor, set the Visible state to true when you want it shown in the Popup, but always set Width to 0. Setting the Width to 0, will show it in the popup, but "hide" it in the grid.

<GridColumn Title="Password" Field="@nameof(UserModel.Password)" Visible=@addingNewUser Width="0"/>

improwise
Posted on: 06 Jan 2022 11:25
I agree with @Christopher here, not having a proper solution for this is honestly quite bad and the suggested solution of toggling Visible on the fly (and having the column show up in the grid behind) feels more like a hack than a solution. 
Christopher
Posted on: 22 Nov 2021 23:32

Unfortunately, the proposed solution is janky because the columns become visible in the grid while editing. It is often the case that one may want to show more information on the create/edit form than in the grid and it would be nice (less code) to handle this without a custom form. I propose that there should be a separate 'VisibleInPopupMode' flag that is evaluated when 'Visible' = false.

Ben Hayat
Posted on: 06 Apr 2021 16:58

Thanks Marin;

With the sample & video, I think we can accomplish what I was looking for.
Thank you for monitoring the feedback.

ADMIN
Marin Bratanov
Posted on: 06 Apr 2021 16:48

Hello all,

We have had very little interest in this, especially considering such functionality can be implemented through the Visible parameter the columns have had for a while. The opener post also contains an example. We have also had no constructive feedback on how else this should be exposed. Therefore, I am marking this as a Completed feature because it is possible and we haven't had better suggestions on how this should be done than our Visible solution.

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

ADMIN
Marin Bratanov
Posted on: 25 Feb 2021 19:36

Hi Chris,

The Visible and Editable parameters have different functions and they must not get mixed together. The Editable parameter control whether an editor is rendered for the column when it  goes in edit/insert mode, otherwise it shows the current value (or, the EditorTemplate and Template if you prefer to think of this in terms of templates). The Visible parameter controls whether the column is rendered at all. It would be used for responsive designs to hide some columns on smaller screens, and it is also used by the end user to hide columns they don't want to look at through the column chooser in the column menu. Thus, Visible is a user setting, that is tied to UI, and goes in the grid state, while Editable is a developer setting the user cannot interfere with.

That said, I am attaching here a small sample and a short video that show how you can have different columns (fields) in the popup form without a custom popup form and without altering anything in the grid behavior. It is literally a few lines of code - on OnClick handler for the Add button, a handler for OnEdit, and they both simply raise a flag. Then lowering that flag in the other CRUD events and using that flag for the Visible parameter of the special column is all it takes.

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Attached Files:
Chris
Posted on: 25 Feb 2021 19:01

Also, due to this being declined, your example doesn't work for the Add pop-up: OnEdit Event not triggered when using the Add command. (telerik.com)

 

Chris
Posted on: 25 Feb 2021 18:57

Marin: Would it be possible to have it such that if you explicitly set `Visible="false" Editable="true"`, the field would show in the edit pop-up?

It seems unlikely that a developer would confuse such behavior.

For this, Editable could become a nullable bool? and default to matching Visible (as is the current case).

ADMIN
Marin Bratanov
Posted on: 26 Aug 2020 17:23

Hi again,

With the upcoming 2.17.0 release, the columns will have a Visible parameter that you can toggle when the grid is in edit/insert mode. I am attaching here a small sample and a video of the expected that shows how that would work. Would that be suitable behavior, or would you expect something else from the grid (we still do not find the that third bullet to be a well-defined scenario for the grid).

 

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Attached Files:
ADMIN
Marin Bratanov
Posted on: 20 Jul 2020 07:18

Hello Andrew,

A Visible parameter is likely to get exposed for this one. It would, however, control the general column visibility in both the grid, and the popup. Perhaps you might be able to toggle it in the OnEdit event, but I can imagine this would be rather cumbersome.

That said, how you you expect a parameter to control the visibility of a column in the popup, considering it is not declared in the grid? At the moment, for a column to be visible AND editable in the grid it must be declared. If you set its Editable parameter to false, it won't show up in the popup editor at all (there is also a way to make it non-editable through data-annotation attributes, see here).

So, I can see the following three scenarios:

  • you want to both show a field and edit it - just declare a column for it
  • you want to show a column but not edit the given field - you declare a column but set its Editable parameter to false
  • you want to NOT show a column, but edit its field - that's the scenario that is unclear and we find confusing. How would you expect that to be exposed for configuration?

 

 

Regards,
Marin Bratanov
Progress Telerik

Andrew
Posted on: 19 Jul 2020 01:34
I thinking having an IsVisible parameter on the GridColumn would be suffice. I get why you're wanting to limit confusion, but setting a grid column with such parameter should be enough of an explicit way of doing so. Just like with your Editable parameter. Please reconsider this, as although this can be achieved through a custom template as you said, having this option should provide additional flexibility within the control realms itself.
Ben Hayat
Posted on: 15 May 2020 16:10
Then I'm happy with Custom form. :-)
Thank you my friend!
ADMIN
Marin Bratanov
Posted on: 15 May 2020 13:34

Hello Ben,

With a custom edit form you can edit however many fields you like, and you can even switch models as suitable for your app - the grid will not be limiting or controlling that in any way.

To take the example - if you define 3 out of the 5 fields of the model in the grid, you can have the following behavior:

  • the built-in popup editing will let you edit/insert those three
  • a custom form can let you edit all 5, a subset of them, or an entirely different model

For cases where you want the grid to show one thing, but the user to see another, a custom form is the solution we have - the grid offers API to let you invoke that form with the desired business logic.

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Ben Hayat
Posted on: 15 May 2020 13:17

Hi Marin;

>>Thus, at this point we believe that the best way to handle such cases is to use a custom edit form<<

Let me see if I understand you correctly; Say, I have a Customer model, that has 5 properties. I assign 3 properties to the grid, to keep the size down. Are you saying, with Custom Edit Form, I can edit ALL the 5 properties of Customer model or ONLY the 3 that I assigned to Grid?

What I was trying to say in my original post was, we usually need more properties to edit than what is shown in the grid.
If we have a large model and we need to edit most of the properties or create those, it would make the grid too big and too much data has to be transferred. I don't mind staying with a single model, but we need to be able (as an option) to be able to declare what properties to be in Edit form and Create for. If this declaration has not been set by developer, then the default would be the properties assigned to Grid.

Hope this clarifies my point.
Thanks!
..Ben

 

ADMIN
Marin Bratanov
Posted on: 15 May 2020 12:42

Hi Ben,

The popup shows only the editable fields defined in the grid. If you set Editable=false to a column it won't appear in the popup. The goal is to have a clear visual mapping between what the user sees in the grid and the edit form so they don't get confused.

Also, the grid can be bound to one model - it is used for displaying, inserting, editing and deleting records, and using a different one would pose several major problems - unnecessary code complexity notwithstanding, it will be a breaking change for everyone (including people who don't need or use such a feature), and it will cause confusion for the users to see one thing in the grid, another when editing, and a third when inserting a record.

Thus, at this point we believe that the best way to handle such cases is to use a custom edit form as shown in this sample project https://github.com/telerik/blazor-ui/tree/master/grid/custom-popup-form or in this demo: https://demos.telerik.com/blazor-ui/grid/editing-custom-form. This will let you use whicever models you want in the forms, and have different forms for editing and inserting - the grid allows you to have full flexibility in this regard, while handling the most common scenarios out-of-the-box.

On large models with a lot of fields - the AutoGeneratedColumns can let you do that, and they also let you specify fields to skip and read-only fields: https://docs.telerik.com/blazor-ui/components/grid/columns/auto-generated.

That said, I am keeping this open for a while so we can gather some more feedback on this to see if anyone else wants to see the same thing.

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.