We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Command column wrong title sent

Thread ID:

Created:

Updated:

Platform:

Replies:

145701 Jul 4,2019 11:26 AM UTC Jul 5,2019 10:19 AM UTC Blazor 1
loading
Tags: Grid
Ivan Petrov
Asked On July 4, 2019 11:28 AM UTC

Hello,

when clicking on either of the two buttons in my command column it always sends the name of the second one. In my case the code is:
@page "/"
@using Data
@using Syncfusion.EJ2.Blazor.Grids
@using Syncfusion.EJ2.Blazor.Popups
@using Newtonsoft.Json;

@if (this.IsModalShown)
{
   
        smt
       
   
}
@**@

         AllowFiltering="true" CommandClicked="@CommandClickHandler">
   
   
       
       
       
       
       
   

@functions{
    EjsGrid defaultGrid;

    public bool IsModalShown { get; set; }

    List commands = new List();

    public List gridData { get; set; }

    protected override async Task OnInitAsync()
    {
        await base.OnInitAsync();
        this.commands.Add(new CommandModel { Title = "Delete", ButtonOption = new CommandButtonOptions {IconCss="e-btn-sb-icons e-open-icon" , CssClass = "e-small e-round" } });
        this.commands.Add(new CommandModel { Title = "Edit", ButtonOption = new CommandButtonOptions {IconCss="e-btn-sb-icons e-add-icon",  CssClass = "e-small e-round" } });
        
        this.gridData = OrdersDetails.GetAllRecords();
    }

    public void CommandClickHandler(CommandClickEventArgs args)
    {
        var selectedId = JsonConvert.DeserializeObject(args.RowData.ToString()).CustomerID;
        switch (args.CommandColumn.Title)
        {
            case "Edit":
                IsModalShown = true;
                this.Invoke(this.StateHasChanged);
                break;
            case "Delete":
                this.DeleteCategory(selectedId);
                break;
        }
    }

    public void DeleteCategory(string id)
    {

    }

    protected override void OnAfterRender()
    {
        base.OnAfterRender();
        this.defaultGrid.GridLines = GridLine.Both;
    }
}

Thus, args.CommandColumn.Title is always equal to "Edit".

Rahul Narayanasamy [Syncfusion]
Replied On July 5, 2019 10:19 AM UTC

Hi Ivan, 
 
Greetings from Syncfusion. 
 
Query: Command column wrong title sent. args.CommandColumn.Title is always equal to "Edit". 
 
We have checked the code snippet that you have shared with us and found that you have not specified the type for the command column items which is the cause of an issue. You can resolve the reported problem by defining CommandButtonType property. Please find the below code example and sample for your reference. 
 
[code example] 
... 
 
<EjsGrid @ref=this.defaultGrid DataSource=@this.gridData ShowColumnChooser="true" Toolbar="@(new List<string>() { "ColumnChooser", "Search" })" 
         AllowFiltering="true" CommandClicked="@CommandClickHandler"> 
    <GridFilterSettings Type="@Syncfusion.EJ2.Blazor.Grids.FilterType.Menu"></GridFilterSettings> 
    <GridSearchSettings Fields="@search" Operator="contains" Key="Denmark" IgnoreCase="true"></GridSearchSettings> 
    <GridColumns> 
        ... 
       <GridColumn HeaderText="Actions" Commands=commands></GridColumn> 
    </GridColumns> 
</EjsGrid> 
 
@functions{ 
 
    ... 
 
    protected override async Task OnInitAsync() 
    { 
        await base.OnInitAsync(); 
        this.commands.Add(new CommandModel { Type = CommandButtonType.Delete, Title = "Delete", ButtonOption = new CommandButtonOptions { IconCss = "e-btn-sb-icons e-open-icon", CssClass = "e-small e-round" } }); 
        this.commands.Add(new CommandModel { Type= CommandButtonType.Edit,Title = "Edit", ButtonOption = new CommandButtonOptions { IconCss = "e-btn-sb-icons e-add-icon", CssClass = "e-small e-round" } }); 
 
        this.gridData = OrdersDetails.GetAllRecords(); 
    } 
 
    public void CommandClickHandler(CommandClickEventArgs args) 
    { 
        var selectedId = JsonConvert.DeserializeObject<OrdersDetails>(args.RowData.ToString()).OrderID; 
        switch (args.CommandColumn.Title) 
        { 
            case "Edit": 
                IsModalShown = true; 
                this.Invoke(this.StateHasChanged); 
                break; 
            case "Delete": 
                this.DeleteCategory(selectedId); 
                break; 
        } 
    } 
 
    ... 
} 
 
 
Please get back to us if you need further assistance. 
 
Regards, 
Rahul 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon