简体   繁体   English

如何在剑道网格中单击更改行颜色

[英]How to change the row colour on click in kendo grid

I have a Kendo grid which is populating all the records correctly.When I select a particular row I want to change the colour of that particular row.I am able to select only one row and colour is changing for that.When I click on second row thing doesn't work.I am not able to select the second row and first row remain selected.I am not able to deselect the first row also.Any help will be appreciated. 我有一个Kendo网格,可以正确填充所有记录。当我选择某一行时,我想更改该行的颜色。我只能选择一行,并且该行的颜色正在更改。当我单击第二行时行的东西不起作用。我无法选择第二行,第一行保持选中状态。我也无法取消选择第一行。我们将不胜感激。

here is OnChange Event: 这是OnChange事件:

    var grid = $("#GridTruck").data("kendoGrid");
    var selectedItem = grid.dataItem(grid.select());
    $("#GridTruck").selectedItem.Class("color", "green");
   Please help me where I am going wrong

You need to set Multi Row selection on the Grid. 您需要在网格上设置多行选择。

.Selectable(s => s.Mode(GridSelectionMode.Multiple).Type(GridSelectionType.Row))

You are only adding the color when selecting but are failing to remove the color when it is de-selected. 您仅在选择时添加颜色,但是在取消选择颜色时无法将其删除。 Instead alter the k-state-selected css class and you will not have to manipulate it manually. 而是更改k-state-selected css类,您将不必手动对其进行操作。

.k-grid .k-state-selected {
        color: green;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM