Jude Duran
Jude Duran

Reputation: 2205

KendoUI Grid make specific rows unselectable

I have this settings for the grid:

 @(Html.Kendo().Grid<RoTechnicianAssignmentOperationModel>()
        .Name("Grid")
        .
        .
        .Selectable()
    )

I use this jQuery code to add disabled class to specific rows:

$("tr.disabledRows").addClass("k-state-disabled");

It only grays-out the row but it is still selectable. Is it possible to make specific rows of a Kendo Grid unselectable?

Upvotes: 2

Views: 6991

Answers (1)

BENARD Patrick
BENARD Patrick

Reputation: 30975

Can you look on this fiddle : http://jsfiddle.net/LL3GN/658/

In it, you have an array of id we don't want to select. On rowChange function, you need just to remove the class that make selected effect. [line 11 to 22 fiddle js:]

var todeselect = new Array();
todeselect[0]='2';
todeselect[1]='3';

function checkline()
{
    var id = $('.k-state-selected td').html();
    if( jQuery.inArray(id, todeselect) >= 0 )
    {
        $('.k-state-selected').removeClass('k-state-selected k-state-selecting'); 
    }    
}

In the kendo grid construction, you call this function on the change event : [line 30 fiddle js]

change: checkline,

In this exemple, id is equal to 'td' because the id is in first column.

Upvotes: 3

Related Questions