javascript - Kendo Grid 删除所有列

标签 javascript jquery kendo-grid

我正在研究 Kendo Grid(启用排序)。删除事件工作正常,但是一旦我删除剑道网格中的所有行并再次按列标题,它就会开始显示所有已删除的数据。任何人都知道我做错了什么

function GetManagePlanData(_data) {

$.each(_data, function (key, value) {

    if (value.Bonus == 'False')
        $('#chkBonusHeader').attr('checked', false);
    else if (value.MeritIncrease == 'False')
        $('#chkMeritIncHeader').attr('checked', false);
});
var isAllBonusSelected = true, isAllMeritSelected = true, isAllStockSelected = true;

$("#tblEligibleEmployees").kendoGrid({
    dataSource: {
        data:_data,
        group: [{ field: "ManagerName" }],// Add manager name here
        schema: {
            model: {
                fields: {
                    ManagerRelationRefID: { type: "string" },
                    EmployeeRelationRefID: { type: "string" },
                    ManagerName: { type: "string" },
                    EmployeeCode: { type: "string" },
                    FullName1: { type: "string" },
                    JoiningDate: { type: "string" },
                    BusinessUnitName: { type: "string" },
                    FTE: { type: "string" },
                    Salary: { type: "string" },
                    HourlyRate:{ type: "string" },
                    EmpStatus: { type: "string" },
                    MeritIncrease: { type: "bool" },
                    Bonus: { type: "bool" },
                    BonusTarget: { type: "double" },
                    Stock: { type: "bool" },
                    BonusBase: { type: "decimal" },
                    Delete : { type: "string" }

                }
            }
        },
        //pageSize: 20
    },
    scrollable: false,
    sortable: true,
    filterable: false,
    groupable:false,
    //pageable: {
    //    input: false,
    //    numeric: false
    //},
    columns: [
        { field: "ManagerName", hidden: true, title: "Manager Name" },//resource required manager name
        { field: "ManagerRelationRefID", hidden: true, template: "<input id=hdnManagerID#=EmployeeRelationRefID# value=#=ManagerRelationRefID# />" },
        { field: "EmployeeRelationRefID", hidden: true, template: "<input id=hdnEmployeeID#=EmployeeRelationRefID# value=#=EmployeeRelationRefID# />" },
        { field: "EmployeeCode", title: key_EmployeeId, width: "90px" },
        { field: "FullName1", title: key_fullname, width: "140px" },
        { field: "JoiningDate", title: key_hiredt, width: "110px" },
        { field: "BusinessUnitName", title: Key_Location, width: "90px" },
        {
            field: "Salary", title: key_Salary, width: "90px", template: FormatSalary
        },
        {
            field: "HourlyRate", title: 'Hourly Rate', width: "90px", template: FormatHourlySalary
        },
        { field: "FTE", title: Key_FTE, width: "80px" },
        { field: "EmpStatus", title: key_status, width: "70px" },
        {
            field: "MeritIncrease", title: key_MeritIncrease, template: ApplyMeritChecks, width: "100px",
            hidden: (isMeritIncrease == 0 ? true : false),
            headerTemplate: '<input type="checkbox" id="chkMeritIncHeader"  >' + key_MeritIncrease + ' </input>',
            sortable:false
        },
        {
            field: "Bonus", title: key_Bonus, template: ApplyBonusChecks, width: "100px",
            hidden : (isBonus==0 ? true:false),
            headerTemplate: '<input type="checkbox" id="chkBonusHeader">' + key_Bonus + ' </input>',
            sortable: false
        },
        { field: "BonusTarget", title: key_BonusTarget, template: FormatBonusTarget, width: "70px",  hidden : (isBonus==0 ? true:false) },
        {
            field: "Stock", title: key_Stock, template: ApplyStockChecks, width: "60px",
            hidden: (isStock == 0 ? true : false),
            headerTemplate: '<input type="checkbox" id="chkStockHeader" /><label>' + key_Stock + '</label>'
        },
        {
            field:"BonusBase",title:"Bonus Base" ,width:"80px",
        template:ApplyBonusBase,
            sortable:false
        },
        {
            field:"Delete",title:"",width :"80px",template:ApplyDelete,sortable:false
        }
    ]


}).data("kendoGrid");
$('.k-grid-header .k-header').css('font-weight', 'bold');
$('.k-header[data-field="Delete"]').css('text-indent', '-9999px');

}


function deleteRow(ID) {
jConfirm2(key_Yes, key_No, key_PlanDeleteMsg, "", function (r) {
    if (r == true) {

        var nxtRow = $('#btndelete-' + ID).parent().parent().next('tr').hasClass("k-grouping-row");
        var prvRow = $('#btndelete-' + ID).parent().parent().prev('tr').hasClass("k-grouping-row");
        var nxtRowlength = $('#btndelete-' + ID).parent().parent().next('tr').length
       // if ((nxtRow || nxtRowlength == 0) && prvRow) {

            //var rowToDelete = $('#btndelete-' + ID).parent().parent().prev('tr');
            var nextRow = $('#btndelete-' + ID).parent().parent().closest('tr');
            var grid = $("#tblEligibleEmployees").data("kendoGrid");
           // grid.removeRow(rowToDelete);
            grid.removeRow(nextRow);

    }
    });
}

请让我知道我做错了什么吗?

最佳答案

删除记录后请尝试刷新剑道网格。以下是代码。

$('#GridName').data('kendoGrid').refresh();

关于javascript - Kendo Grid 删除所有列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28405046/

相关文章:

javascript - jQuery 不创建区域标签

plugins - 使用附加构造函数参数扩展 kendoGrid

java - 在 C、C++ 和 Java 中提升/重新排序 : Must variable declarations always be on top in a context?

javascript - 找到按钮(onclick)并单击所有按钮

JavaScript 或 jQuery 浏览器后退按钮点击检测器

javascript - Knockout JS foreach 循环中的非重复元素

Javascript 添加/删除文本框和相应的删除按钮

kendo-ui - 过滤网格数据在 FF(mozilla) 和 IE 中不起作用

javascript - 数据绑定(bind)剑道 ui 网格与外部 API

javascript - 访问网格中的不同复选框