0

我用 NonFactors.Grid.Mvc5 库制作了下表。

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

我使用 NonFactors.Grid.Mvc5 库创建的表

我需要找到一种方法来在用户单击“应用程序”列标题时禁用列排序,并且仅在单击它旁边的排序按钮时才允许排序?

我使用了 stopPropagation 方法,但它不起作用。

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

1 回答 1

0

我可以通过使用e.stopImmediatePropagation()函数来做到这一点。现在它起作用了。

<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();
    });
});
于 2021-09-03T08:32:57.423 回答