Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.26k stars 528 forks source link

DataGrid : Evaluation of Editable throw exception on New Command #4958

Open David-Moreira opened 1 year ago

David-Moreira commented 1 year ago
          I now have:
        <DataGridNumericColumn TItem="ReporterRemark"
                               Field="@(nameof(ReporterRemark.Id))"
                               Caption="Code"
                               Editable="true"
                               Readonly="@(_grid.EditState != DataGridEditState.New)">

I think it would be nicer if I could use the @context instead of the reference to the grid.

I first tried this on the editable property, but that gave the unwanted side-effect that the other column is not editable any more while inserting. Maybe I should report a bug for that?

          <DataGridNumericColumn TItem="ReporterRemark"
                         Field="@(nameof(ReporterRemark.Id))"
                         Caption="Code"
                         Editable="@(_grid.EditState == DataGridEditState.New)"
                         Readonly="false">
            <SortDirectionTemplate>
                <SortTemplate Direction="@context" />
            </SortDirectionTemplate>
        </DataGridNumericColumn>
        <DataGridColumn TItem="ReporterRemark"
                        Field="@(nameof(ReporterRemark.Remark))"
                        Caption="Omschrijving"
                        Editable="true">
            <SortDirectionTemplate>
                <SortTemplate Direction="@context" />
            </SortDirectionTemplate>
        </DataGridColumn>

This is the result when inserting with logic on the Editable property image With reverse logic on the Readonly this side-effect does not occur

Originally posted by @tacoWanneeJama in https://github.com/Megabit/Blazorise/issues/4946#issuecomment-1696884052

David-Moreira commented 1 year ago

It was verified that Editable="@(dataGrid.EditState == DataGridEditState.New)" throws an exception on New Command.

This was verified in the Blazorise demo DataGridPage.