This is a migrated thread and some comments may be shown as answers.

I need my custom delete button, to delete records associated with my check box while batch editing is enabled.

1 Answer 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
Veteran
David asked on 05 Feb 2020, 07:15 PM

I currently have a a custom delete button in my toolbar. I want it to delete any record that has a check beside it in the grid with my Checkbox column. I also have batch editing enabled as well as Selectable as a way to see which record correlates with what you are doing. Here is my code. 

 

@(Html.Kendo().Grid<MVCSQLDatabase.Models.Proposal>()
      .Name("Grid")
      .DataSource(dataSource => dataSource
          .Ajax()
          .PageSize(10)
          .Batch(true)
          .Model(model => model.Id(p => p.Proposal_Uid))
          .Read(read => read.Action("Proposals_Read", "Grid"))
          .Create(create => create.Action("Proposals_Create", "Grid"))
          .Update(update => update.Action("Proposals_Update", "Grid"))
          .Destroy(destroy => destroy.Action("Proposals_Destroy", "Grid"))
      )
          .Resizable(resize => resize.Columns(true))

      .Columns(columns =>
      {
          columns.Select().Width(100);
          columns.Bound(c => c.Pr).Width(215);
          columns.Bound(c => c.P).Width(200);
          columns.Bound(c => c.C).Width(190);
          columns.Bound(c => c.Cli).Width(185);
          columns.Bound(c => c.Total).Width(290);
          columns.Bound(c => c.Md).Width(220);
          columns.Bound(c => c.Start_Date).Format("{0: dd/MM/yyyy}").Width(170);
          columns.Bound(c => c.End_Date).Format("{0: dd/MM/yyyy}").Width(170);
          columns.Bound(c => c.Pqr).Width(235);
          columns.Bound(c => c.Co).Width(215);
      })
      .ToolBar(toolbar =>
          {
          toolbar.Create();
          toolbar.Save();
          toolbar.Excel();
          toolbar.Custom().Text("Delete").Name("Destroy").IconClass("k-icon k-i-close");
      })
      .ColumnMenu()
      .Editable(editable => editable.Mode(GridEditMode.InCell))
      .Pageable()
      .Selectable(selectable =>
          {
          selectable.Mode(GridSelectionMode.Multiple);
          selectable.Type(GridSelectionType.Row);
      })
      .PersistSelection()
      .Filterable(filterable => filterable.Mode(GridFilterMode.Row))
      .Scrollable()
      .HtmlAttributes(new { style = "height:835px;" })


)

 

It should delete from the grid AND my server when I put a checkmark in the check box and hit the delete button in the tool bar. It should also Delete as many records as I choose, and if I put a check in the box at the column header, it should delete all records. It should also only give 1 event of deletion regardless of how many records are actually deleted. I know I need a script, but I currently don't know how to write it correctly. Any help would be appreciated. 

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 06 Feb 2020, 02:26 PM

Hi, David,

I believe that the original forum post has all the information necessary so I suggest we treat this as duplicate and continue the conversation there. I responded to you in this post:

https://www.telerik.com/forums/in-my-grid-toolbar-i-need-the-delete-button#aHXysds7P02ke1NSgN2Kww

Regards,
Alex Hajigeorgieva
Progress Telerik

Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Veteran
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or