同位素多重排序,具有上升和下降的混合

时间:2022-05-04 07:40:52

I'm using the Isotope jQuery plugin to sort some tabular data. That's all working fine, but now I need to sort on multiple columns, which is documented.

我正在使用Isotope jQuery插件来排序一些表格数据。这一切都运行正常,但现在我需要对多列进行排序,这是有记录的。

The problem is that some of the columns need to be sorted ascending, and other descending. According to the documentation Isotope works by setting a set of values and a direction for those values, and not a mixture of the two. See below:

问题是某些列需要按升序排序,而其他列则需要降序排序。根据文档,Isotope通过为这些值设置一组值和方向来工作,而不是两者的混合。见下文:

var $container = $('#multiple-sort-by .isotope').isotope({
  // sort by color then number
  sortBy: [ 'color', 'number' ],
  sortAscending: true
});

Is it possible?

可能吗?

Syntax I would expect might be:

我期望的语法可能是:

var $container = $('#multiple-sort-by .isotope').isotope({
  // sort by color then number
  sortBy: {
      [ 'color', 'asc' ],
      [ 'number', 'desc' ],
  }
});

1 个解决方案

#1


4  

I found a different area of the documentation that outlines how to do this. Instead of my suggested syntax, you can instead provide an object to sortAscending.

我发现文档的不同区域概述了如何执行此操作。您可以改为提供sortAscending的对象,而不是我建议的语法。

EG:

例如:

$container.isotope({ 
    sortBy: sortValue,
    sortAscending: {
        color: true,
        number: false,
    }
});

#1


4  

I found a different area of the documentation that outlines how to do this. Instead of my suggested syntax, you can instead provide an object to sortAscending.

我发现文档的不同区域概述了如何执行此操作。您可以改为提供sortAscending的对象,而不是我建议的语法。

EG:

例如:

$container.isotope({ 
    sortBy: sortValue,
    sortAscending: {
        color: true,
        number: false,
    }
});