blazorbootstrap icon indicating copy to clipboard operation
blazorbootstrap copied to clipboard

Grid: Conditional rendering of GridColumn is not working

Open joselitogatchalianalonzo opened this issue 2 years ago • 5 comments

I have below code in my Razor file: @if (!disableForm) { GridColumn TItem="OfficialBusinessLog" HeaderText="Delete"
button type="button" class="btn btn-danger" @onclick="(async () => await DeleteLogAsync(context))" DELETE ROW
button GridColumn }

My objective on above code is to hide the GridColumn when I set the disableForm=true. In my cs file, I set disableForm = true when user clicks the Approve button. However, the GridColumn Delete is still visible. My use case in this scenario is to prevent user from making changes on the form e.g. deleting row on the grid if the document was already approved. That's why I want to conditionally hide the GridColumn Delete. Please let me know what's wrong with my code.

Additional Information: During the initial loading of the form and I set disableForm=true, it is working. But when I change the value of disableForm after the Grid was already rendered, it does not work.

@joselitogatchalianalonzo This feature is not supported. Will keep this in our backlog as an enhancement.

gvreddy04 avatar Aug 04 '23 19:08 gvreddy04

Thanks @gvreddy04 I'm looking forward on this enhancement. I need it in my projects.

You could instead try setting the disabled property on the button based on disabledForm like @(disableForm ? "disabled" : "") or Disabled="@disableForm" if it's a bb button. You'd also probably need to consider adding a guard against it in DeleteLogAsync by checking that value if you aren't already.

Not quite the UI look of removing the column but should achieve the behavior of preventing unwanted interaction. On the other hand you won't get a visual resizing of the grid which could be a little less visually disruptive since the column will stay there.

thatplatypus avatar Aug 22 '23 04:08 thatplatypus

Thanks @thatplatypus that's also a viable solution. But I think this feature should still be available in Grid because other use case is that maybe you want to hide some columns which are confidential and should never be seen by some users and could be seen by admin users.

@joselitogatchalianalonzo Yeah it would be cool for sure. I think it'd be super easy to support show/hide additional columns from a multi select drop-down or something like that if the conditional worked that easily. Then you could give a really flexible user experience on tables with lots of data past what you might want to show by default for UX reasons too.

thatplatypus avatar Aug 27 '23 23:08 thatplatypus