dgrid ColumnHider,CompundColumns和ColumnReorder不能一起使用

时间:2016-06-30 22:25:51

标签: dgrid

我有一个使用这些扩展的网格,它们似乎不能一起工作。更具体地说,CompoundColumns不适用于ColumnReorder,但如果没有ColumnHider,则ColumnSets无效。我也在使用 var CustomGrid = declare([Grid, CompoundColumns, ColumnSet, Selection, Selector, Keyboard, Editor, ColumnHider, ColumnResizer, ColumnReorder, Pagination]); ,但是有一些示例在测试的src代码中一起显示ColumnSets和ColumnReorder。

 cached_query(key, model, my_filter=None, or_filter={}, exclude=None, order_by=None, sliced=50):
    """
    :param key: string used as key reference to store on Memcached
    :param model: model reference on which 'filter' will be called
    :param my_filter: dictionary containing the filter parameters (eg.: {'title': 'foo', 'category': 'bar'}
    :param or_filter: dictionary containing the filter parameters (eg.: {'title': 'foo', 'category': 'bar'}
    :param sliced: integer limit of results from the query. The lower the better, since for some reason Django Memcached
        won't store thousands of entries in memory
    :param exclude: dictionary containing the exclude parameters (eg.: {'title': 'foo', 'category': 'bar'}
    :param order_by: tuple containing the list of fields upon which the model will be ordered.
    :return: list of models. Not a QuerySet, since it was sliced.
    """

    result = cache.get(key, None)
    if not result:
        result = model.objects.all()
        if my_filter:
            result = model.objects.filter(**my_filter)
        if or_filter:
            reduced_filter = reduce(operator.or_, (Q(**d) for d in [dict([i]) for i in or_filter.items()]))
            result = result.filter(reduced_filter)
        if exclude:
            result = result.exclude(**exclude)
        if order_by:
            result = result.order_by(*order_by)
        result = result[:sliced]
        cache.set(key, result, cache_timeout)
    return result

1 个答案:

答案 0 :(得分:0)

您关于ColumnHider要求CompundColumns的声明不正确。查看this test

添加mixin的顺序非常重要。 ColumnHider, ColumnResizer等必须在CompoundColumns之前,因为它扩展了ColumnHiderColumnResizer方法。

尝试此订单

 var CustomGrid = declare([Grid, Selection, Selector, Keyboard, Editor, ColumnHider, 
 ColumnResizer, ColumnReorder, CompoundColumns, ColumnSet, Pagination]);