At the moment the button types in the DataGridCommandColumn are fixed, but I would like to add some additional / custom buttons, eg a Deactivate/Reactivate button. As far as I can see this isn't possible now
Not sure what you mean. Every command button can be changed with {Name}CommandTemplate. You can see the examples in the docs or in the demo.
If you mean by completely new commands in that case that is not supported and not sure if every will be.
Maybe there could be custom buttons. So that should be CustomFunction1CommandTemplate, CustomFunction2CommandTemplate, etc.
So the buttons being customizable but a generic callback function name. Just an idea.
Or maybe support the DisplayTemplate and EditTemplatate in the DataGridCommandColumn, so I can do something like this:
<DataGridCommandColumn>
<SaveCommandTemplate>...</SaveCommandTemplate>
<EditCommandTemplate>...</EditCommandTemplate>
<DisplayTemplate>
<Button Clicked="@ToggleUserActive">
<Icon Name="@GetActiveState(context)"/>
</Button>
</DisplayTemplate>
</DataGridCommandColumn>
Having DisplayTemplate and EditTemplate does not seems like a bad idea.
@njannink
Where and when should this DisplayTemplate be shown?
Maybe should EditMode a property of context?
<TableRowCell ...>
<--Possible Place-->
...
@Edit/SaveCommandTeplate
...
<--Possible Place-->
...
@Delete/CancleCommandTeplate
...
<--Possible Place-->
</TableRowCell>
Or do you want full access of displaying?
Like this?
<DataGridCommandColumn>
<SaveCommandTemplate>...</SaveCommandTemplate>
<EditCommandTemplate>...</EditCommandTemplate>
<DisplayTemplate>
@context.EditCommandTemplate(context.EditCommandContext)
<Button Clicked="@ToggleUserActive">
<Icon Name="@GetActiveState(context)"/>
</Button>
@context.DeleteCommandTemplate(context.DeleteCommandContext)
</DisplayTemplate>
<EditTemplate>
@context.SaveCommandTemplate(context.SaveCommandContext)
<Button Clicked="@ToggleUserActive">
<Icon Name="@GetActiveState(context)"/>
</Button>
@context.CancleCommandTemplate(context.CancleCommandContext)
</EditTemplate>
</DataGridCommandColumn>
I think the second option gives the most flexibility to the implementers. Probably not a lot will use it, but it will give me the option to add my import and export buttons for example. But on the other hand I now just use the edit and save templates to add additional buttons so I have a workaround
@stsrki What do you think about this?
I guess by using DisplayTemplate and EditTemplate withing DataGridCommandColumn it would be required to define all possible button states. And @AjaxSantos idea is on that track.
I think I asked a similar question, any ideas? #1361
This is how I do it
<DataGridColumn TItem="Order" Field="@nameof( Order.Id)" Sortable="false" Filterable="false" Width="120px">
<DisplayTemplate>
<Button Color="Color.Primary" Clicked="@(()=>OnSendEmailClicked(context.Id))">
Send Email
</Button>
</DisplayTemplate>
</DataGridColumn>
I just use any field to show the column and then use DisplayTemplateto custom action button.
Thanks, I'll see how I can do so that when the button is pressed, the selected row does not highlight
Has there been any resolution to this request? I have the same need to add a custom command.
@njannink Could you share your markup for adding extra buttons to the edit and save templates?
Thanks!
For anyone following, I was able to add an additional button to the Edit template using the following markup...
<EditCommandTemplate>
<Button Clicked="@context.Clicked">@Localization["Markets:Edit"]</Button>
<Button Clicked="@((e)=>OnTransactionsClicked(context.Item))">@Localization["Markets:Transactions"]</Button>
</EditCommandTemplate>
The feature is currently on the backlog and for now, it's has a low priority.