logo
down
shadow

How can i delete multi selected records using checkbox in Kendo Grid?


How can i delete multi selected records using checkbox in Kendo Grid?

By : Anton Herzog
Date : November 19 2020, 01:01 AM
should help you out I want to allow the user to select one or more rows using checkbox in kendo grid and to delete the selected rows, my project is asp.net MVC , In kendo grid add this column
code :
columns.Template(x => { }).ClientTemplate("<input type='checkbox' id='chkSelect_#= yourid#' userId='#= yourid#' />").Width(20);
var grid, dataSource, data = null;
grid = $("#grdImageModel").data("kendoGrid"), dataSource = grid.dataSource, data = dataSource.data();

        $.each(data, function (i, tmpObject) {
            $('tr[data-uid="' + tmpObject.uid + '"] td input[id^="chkSelect_"]:checked').each(function (k, input) {
                // here you are access the checked row object
            });
        });


Share : facebook icon twitter icon
How to filter the kendo ui grid with multi selection of dropdownlist with checkbox plugin

How to filter the kendo ui grid with multi selection of dropdownlist with checkbox plugin


By : Nick Nguyen
Date : March 29 2020, 07:55 AM
it fixes the issue The kendo team has added a new MultiSelect box. Here is a sample of filtering a grid using one.
http://jsbin.com/ameyam/1/edit
In kendo grid mulitiple checkbox selected geting only one value at jquery reading in mvc4

In kendo grid mulitiple checkbox selected geting only one value at jquery reading in mvc4


By : Shauryanaditya Singh
Date : March 29 2020, 07:55 AM
wish of those help This is my kendo grid
code :
  // getting kendo grid 
  var grid = $("#grid1").data("kendoGrid");

  // list of selected and unselected books
  var books = [];

  // getting all the checked rows
  grid.tbody.find("input:checked").closest("tr").each(function (index) {
    grid.select($(this));
    var dataItem = grid.dataItem($(this));
    dataItem.assetcheck = 'true';
    books.push(dataItem);
  });

  // getting all the unchecked rows
  grid.tbody.find("input:not(:checked)").closest("tr").each(function (index) {
    grid.select($(this));
    var dataItem = grid.dataItem($(this));
    dataItem.assetcheck  = 'false';
    books.push(dataItem);
  });
How to delete all records from a Kendo paged and filtered grid (in the controller)

How to delete all records from a Kendo paged and filtered grid (in the controller)


By : user2032195
Date : March 29 2020, 07:55 AM
help you fix your problem Ok I don't know if there is better solution but I found this one. I don't pretend that it is perfect.
You can use the idea with custom button and attach click event to it. In the click event handler you must extract what you need (filters, sortings etc.) from the data source. All the DataSourceRequest class properties can be extracted from JavaScript dataSourceo object:
code :
dataSource.sort() dataSource.filter(), dataSource.group(),
dataSource.aggregate(), dataSource.page(), dataSource.pageSize()
function deleteAllEventHandler(){
   var dataSource = $('#Grid').data('kendoGrid').dataSource;

   var dataSourceRequest = dataSource.transport.parameterMap({
        sort: dataSource.sort(),
        filter: dataSource.filter(),
        group: dataSource.group(),
        aggregate: dataSource.aggregate(),
        page: dataSource.page(),
        pageSize: dataSource.pageSize()
   });

   var data = "";

   for (var key in dataSourceRequest) {
       if (dataSourceRequest[key] !== undefined) {
           data += key + "=" + dataSourceRequest[key] + "&";
       }
   }

   $.ajax({
        type: "POST",
        contentType: "application/x-www-form-urlencoded; charset=UTF",
        url: "@Html.Action("DeleteAllAction", "MyController")",
        data: data,
        success: function(){
            dataSource.read();
        }
   });
}
public ActionResult DeleteAll([DataSourceRequest] DataSourceRequest request)
{
    // Here you must parse the request to expression tree with custom logic
    // or use the folliwng logic:

    // It's very important to return IQueryable here so you can apply kendo
    // filters without fetching all data from the dataprovider (sql server)
    var items = YourDataProvider.GetQueryableItems();

    // Applying the kendo filters on your queryable.
    // I don't know if there is a better way but I use this one. 
    var result = items.ToDataSourceResult(); 

    // Delete items
    YourDataProivder.DeleteItems(result.Data);

    // return Success 
    return new HttpStatusCodeResult(200);
}
How to order a Kendo Grid checkbox column filter when multi and columnMenu are both true?

How to order a Kendo Grid checkbox column filter when multi and columnMenu are both true?


By : Mark Schmidt
Date : March 29 2020, 07:55 AM
Hope this helps I came here looking for an answer to this question also, and I tried Bill's solution and it works great...as long as you don't have any locked columns.
Bill's solution, based on the Kendo UI docs:
code :
columnMenuInit: function (e) {
    var multiCheck = this.thead.find("[data-field=" + e.field + "]").data("kendoColumnMenu").filterMenu.checkBoxAll;
    if (multiCheck) {
        var filterMultiCheck = this.thead.find("[data-field=" + e.field + "]").data("kendoColumnMenu").filterMenu
        filterMultiCheck.container.empty();
        filterMultiCheck.checkSource.sort({ field: e.field, dir: "asc" });
        filterMultiCheck.checkSource.data(filterMultiCheck.checkSource.view().toJSON());
        filterMultiCheck.createCheckBoxes();
}
columnMenuInit: function (e) {
    let lockedColumn = false;
    let columnMenu = this.thead.find("[data-field=" + e.field + "]").data("kendoColumnMenu");

    // if columnMenu is falsy this may be a locked column, in which case we need to target the column menu from the lockedHeader property
    if (!columnMenu) {
        columnMenu = this.lockedHeader.find("[data-field=" + e.field + "]").data("kendoColumnMenu");
        lockedColumn = true;
    }

    if (columnMenu) {
        const multiCheck = columnMenu.filterMenu.checkBoxAll;

        // if this column uses multi-check filtering, sort the filter options in ascending alphabetical order
        if (multiCheck) {
            const filterMultiCheck = lockedColumn ? this.lockedHeader.find("[data-field=" + e.field + "]").data("kendoColumnMenu").filterMenu : this.thead.find("[data-field=" + e.field + "]").data("kendoColumnMenu").filterMenu;
            filterMultiCheck.container.empty();
            filterMultiCheck.checkSource.sort({ field: e.field, dir: "asc" });
            filterMultiCheck.checkSource.data(filterMultiCheck.checkSource.view().toJSON());
            filterMultiCheck.createCheckBoxes();
        }
    }
}
Unable to check the multi-select checkbox filter of the Kendo Grid Programmatically

Unable to check the multi-select checkbox filter of the Kendo Grid Programmatically


By : Video Pub
Date : March 29 2020, 07:55 AM
it helps some times It works like that because in time, when you are trying to check those checkboxes - they don't exist yet. They are created after user click on filter icon.
From that reason, there is filterMenuInit event which is fired after filter is created. You can do your logic in there.
code :
$(document).ready(function(){
       $("#grid").kendoGrid({
        columns: [ {
            field: "country",
            filterable: {
                multi:true,
                itemTemplate: function(e) {
                   
                      return "<div><input type='checkbox' data-text='#= data.country #' /><span>#= data.country|| data.all #</span></div>"
                    
                }
            }
        }],
        filterable: true,
        filterMenuInit: function(e){
          if(e.field == "country")
        {
            //$(".k-multicheck-wrap >div >input").prop("checked", true)
            $(".k-multicheck-wrap >div >input[type=checkbox][data-text='BG']").prop("checked", true)
        }
        },
      
        dataSource: [ { country: "BG" }, { country: "USA" } ]
    });
  });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2019.1.220/js/kendo.all.min.js"></script>

 <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.1.220/styles/kendo.common.min.css"/>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.1.220/styles/kendo.rtl.min.css"/>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.1.220/styles/kendo.silver.min.css"/>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2019.1.220/styles/kendo.mobile.all.min.css"/>
    
    <div id="grid"></div>
Related Posts Related Posts :
  • How to use c# inside mvc razor pages
  • Reasons not to increase maxQueryStringLength?
  • asp.net mvc exclude an action from search engine crawling
  • Best Way to reuse code inside my Controller action method
  • BEM and asp.net mvc
  • RazorPDF save pdf file to server directory in MVC4
  • Controller Unit Testing with model validation
  • How to bind input field to editfor model MVC
  • How can I restrict access to a view only to two specific users each time in MVC?
  • How to modify CRUD operations with Entity Framework in .NET MVC application
  • ModelBinding Issue with a Struct
  • issue in adding elements into a list in mvc
  • IActionFilter class can only find physical attributes, not ones added in GlobalFilters config
  • ASP.NET MVC Bug with Model Binding: "Specified cast is not valid" when no data provided for dictionary
  • How to reuse class in models without using validation for all of them
  • How to set routing to have some controller actions handled by angular
  • ads while debugging mvc website
  • Does editing a Web.config file trigger an overlapping recycle or a start+stop of the application pool?
  • 404.15 not found MVC4 RazorJS
  • Passing selected value from the radio buttons to the controller in MVC
  • TFS:The "Microsoft.Reporting.RdlCompile" task could not be loaded from the assembly Microsoft.ReportViewer.Web
  • ViewModel in postback to controller is null
  • Get the user id of a username identity 2.0
  • Don't validate date fields on MVC
  • Add class and default value to MVC dropdown that isn't linked to model
  • Passing values from the view to the controller in MVC
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org