LizardKingLK
LizardKingLK

Reputation: 131

How to disable header click sort event in NonFactors.Grid.Mvc5?

I have made the following table with NonFactors.Grid.Mvc5 library.

columns.Add(model => model.ApplicationName).Titled("Application").Filterable(true).Sortable(true);

table I created using NonFactors.Grid.Mvc5 library

I need to find a way to disable column from sorting when user clicks on "Application" column header and allowing sorting only when sort button next to it clicked?

I used stopPropagation method but it does not work.

label.click((e) => e.stopPropagation());

Upvotes: 0

Views: 216

Answers (1)

LizardKingLK
LizardKingLK

Reputation: 131

I could do this by using e.stopImmediatePropagation() function. Now it works.

<script>
var sortables = $('table th').filter('.sortable');
sortables.each((i, e) => {
    var header = $(e);
    header.hasClass('sortable') ? header.removeClass('sortable') : null;
    header.click((e) => {
        e.stopImmediatePropagation();
    });
});

Upvotes: 0

Related Questions