Grid 3 dot button for grid column edit or remove button

1 Answer 483 Views
AnimationContainer DropDownList Grid
Sunil
Top achievements
Rank 1
Sunil asked on 29 Dec 2023, 09:45 AM | edited on 29 Dec 2023, 09:49 AM

For mobile view in column item i want to add the a three dot menu.
On click of that button there will be a popup with two buttons (Like image)
I tried a number of things but not able to figure out which component will be helpful in this condition.

Any help will be appreciated 

(Kendo Blazor) 

 

1 Answer, 1 is accepted

Sort by
0
Nansi
Telerik team
answered on 03 Jan 2024, 09:18 AM

Hi Sunil,

When the user clicks on the three dots, you can use a Context Menu to show the Edit and Remove items. 

Here is a code example and bullet points for achieving the result:

1. Add a TelerikButton in a GridCommandColumn 

<GridCommandColumn>

<TelerikButton Icon="@SvgIcon.MoreVertical" OnClick="@( (MouseEventArgs args) => MyCustomOnClickHandler(args, (SampleData)context) )"> </TelerikButton></GridCommandColumn>

2. Show the Context Menu programmatically with the received coordinates of the button click event:

    private async Task MyCustomOnClickHandler(MouseEventArgs args, SampleData dataItem)
    {
        SelectedPerson = dataItem;
        await ContextMenuRef.ShowAsync(args.ClientX, args.ClientY);
    }

3. Also programmatically enter Grid edit mode through the Grid State:

            case "Edit":
                var currState = GridRef.GetState();
                currState.InsertedItem = null;
                SampleData itemToEdit = SampleData.GetClonedInstance(GridData.Where(itm => itm.ID == SelectedPerson.ID).FirstOrDefault());
                currState.OriginalEditItem = itemToEdit;
                await GridRef.SetStateAsync(currState);
                break;

4. Handle  the removal of the Grid row in the same way as in a desktop view but with manually created GridCommandEventArgs:

 case "Remove":
     var deleteArgs = new GridCommandEventArgs();
     deleteArgs.Item = SelectedPerson;
     OnGridDelete(deleteArgs);
     break;
  private void OnGridDelete(GridCommandEventArgs args)
 {
      SampleData item = (SampleData)args.Item;
      GridData.Remove(item);
  }

Let me know if you need something more. On a side note, please ask the license holder at your company to assign you a license, so that your account is in good standing. Alternatively, activate a trial to show that you are evaluating our product.

Regards, Nansi 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!
Tags
AnimationContainer DropDownList Grid
Asked by
Sunil
Top achievements
Rank 1
Answers by
Nansi
Telerik team
Share this question
or