Add a KE-chain paginatedGrid (e.g. paginated table widget) to the customization.

        The widget will be saved to KE-chain.

        :param emphasize_new_instance: Emphasize the New instance button (default True)
        :type emphasize_new_instance: bool
        :param emphasize_edit: Emphasize the Edit button (default False)
        :type emphasize_edit: bool
        :param emphasize_clone: Emphasize the Clone button (default False)
        :type emphasize_clone: bool
        :param new_instance: Show or hide the New instance button (default False). You need to provide a
            `parent_part_instance` in order for this to work.
        :type new_instance: bool
        :param export: Show or hide the Export Grid button (default True)
        :type export: bool
        :param edit: Show or hide the Edit button (default True)
        :type edit: bool
        :param clone: Show or hide the Clone button (default True)
        :type clone: bool
        :param delete: Show or hide the Delete button (default False)
        :type delete: bool
        :param page_size: Number of parts that will be shown per page in the grid.
        :type page_size: int
        :param collapse_filters: Hide or show the filters pane (default False)
        :type collapse_filters: bool
        :param part_model: The part model based on which all instances will be shown.
        :type parent_part_instance: :class:`Part` or UUID
        :param parent_part_instance: The parent part instance for which the instances will be shown or to which new
            instances will be added.
        :type parent_part_instance: :class:`Part` or UUID
        :param max_height: The max height of the paginated grid in pixels
        :type max_height: int or None
        :param custom_title: A custom title for the paginated grid::
            * False (default): Part instance name
            * String value: Custom title
            * None: No title
        :type custom_title: bool or basestring or None
        :param sort_property: The property model on which the part instances are being sorted on
        :type sort_property: :class:`Property` or UUID
        :param sort_direction: The direction on which the values of property instances are being sorted on::
            * ASC (default): Sort in ascending order
            * DESC: Sort in descending order
        :type sort_direction: basestring (see :class:`enums.SortTable`)
        :raises IllegalArgumentError: When unknown or illegal arguments are passed.

def add_paginated_grid_widget(self, part_model, delete=False, edit=True, export=True, clone=True,
                                  new_instance=False, parent_part_instance=None, max_height=None, custom_title=False,
                                  emphasize_edit=False, emphasize_clone=False, emphasize_new_instance=True,
                                  sort_property=None, sort_direction=SortTable.ASCENDING, page_size=25,
                                  collapse_filters=False):
        """
        Add a KE-chain paginatedGrid (e.g. paginated table widget) to the customization.

        The widget will be saved to KE-chain.

        :param emphasize_new_instance: Emphasize the New instance button (default True)
        :type emphasize_new_instance: bool
        :param emphasize_edit: Emphasize the Edit button (default False)
        :type emphasize_edit: bool
        :param emphasize_clone: Emphasize the Clone button (default False)
        :type emphasize_clone: bool
        :param new_instance: Show or hide the New instance button (default False). You need to provide a
            `parent_part_instance` in order for this to work.
        :type new_instance: bool
        :param export: Show or hide the Export Grid button (default True)
        :type export: bool
        :param edit: Show or hide the Edit button (default True)
        :type edit: bool
        :param clone: Show or hide the Clone button (default True)
        :type clone: bool
        :param delete: Show or hide the Delete button (default False)
        :type delete: bool
        :param page_size: Number of parts that will be shown per page in the grid.
        :type page_size: int
        :param collapse_filters: Hide or show the filters pane (default False)
        :type collapse_filters: bool
        :param part_model: The part model based on which all instances will be shown.
        :type parent_part_instance: :class:`Part` or UUID
        :param parent_part_instance: The parent part instance for which the instances will be shown or to which new
            instances will be added.
        :type parent_part_instance: :class:`Part` or UUID
        :param max_height: The max height of the paginated grid in pixels
        :type max_height: int or None
        :param custom_title: A custom title for the paginated grid::
            * False (default): Part instance name
            * String value: Custom title
            * None: No title
        :type custom_title: bool or basestring or None
        :param sort_property: The property model on which the part instances are being sorted on
        :type sort_property: :class:`Property` or UUID
        :param sort_direction: The direction on which the values of property instances are being sorted on::
            * ASC (default): Sort in ascending order
            * DESC: Sort in descending order
        :type sort_direction: basestring (see :class:`enums.SortTable`)
        :raises IllegalArgumentError: When unknown or illegal arguments are passed.
        """
        height = max_height
        # Check whether the part_model is uuid type or class `Part`
        if isinstance(part_model, Part):
            part_model_id = part_model.id
        elif isinstance(part_model, text_type) and is_uuid(part_model):
            part_model_id = part_model
            part_model = self._client.model(id=part_model_id)
        else:
            raise IllegalArgumentError("When using the add_paginated_grid_widget, part_model must be a Part or Part id."
                                       " Type is: {}".format(type(part_model)))

        # Check whether the parent_part_instance is uuid type or class `Part`
        if isinstance(parent_part_instance, Part):
            parent_part_instance_id = parent_part_instance.id
        elif isinstance(parent_part_instance, text_type) and is_uuid(parent_part_instance):
            parent_part_instance_id = parent_part_instance
            parent_part_instance = self._client.part(id=parent_part_instance_id)
        elif isinstance(parent_part_instance, type(None)):
            parent_part_instance_id = None
        else:
            raise IllegalArgumentError("When using the add_paginated_grid_widget, parent_part_instance must be a "
                                       "Part, Part id or None. Type is: {}".format(type(parent_part_instance)))

        # Check whether the sort_property is uuid type or class `Property`
        if isinstance(sort_property, Property):
            sort_property_id = sort_property.id
        elif isinstance(sort_property, text_type) and is_uuid(sort_property):
            sort_property_id = sort_property
            sort_property = self._client.property(id=sort_property_id, category=Category.MODEL)
        elif isinstance(sort_property, type(None)):
            sort_property_id = None
        else:
            raise IllegalArgumentError("When using the add_paginated_grid_widget, sort_property must be a "
                                       "Property, Property id or None. Type is: {}".format(type(sort_property)))

        # Assertions
        if not parent_part_instance and new_instance:
            raise IllegalArgumentError("If you want to allow the creation of new part instances, you must specify a "
                                       "parent_part_instance")
        if sort_property and sort_property.part.id != part_model.id:
            raise IllegalArgumentError("If you want to sort on a property, then sort_property must be located under "
                                       "part_model")

        # Add custom title
        if custom_title is False:
            show_title_value = "Default"
            title = part_model.name
        elif custom_title is None:
            show_title_value = "No title"
            title = ' '
        else:
            show_title_value = "Custom title"
            title = str(custom_title)

        # Set the collapse filters value
        if collapse_filters:
            collapse_filters_value = "Collapsed"
        else:
            collapse_filters_value = "Expanded"

        # Declare paginatedGrid config
        config = {
            "xtype": ComponentXType.FILTEREDGRID,
            "filter": {
                "activity_id": str(self.activity.id),
            },
            "grid": {
                "viewModel": {
                    "data": {
                        "actions": {
                            "delete": delete,
                            "edit": edit,
                            "export": export,
                            "newInstance": new_instance,
                            "cloneInstance": clone
                        },
                        "sorters": [{
                            "direction": sort_direction,
                            "property": sort_property_id
                        }] if sort_property_id else [],
                        "ui": {
                            "newInstance": "primary-action" if emphasize_new_instance else "default-toolbar",
                            "edit": "primary-action" if emphasize_edit else "default-toolbar",
                            "cloneInstance": "primary-action" if emphasize_clone else "default-toolbar"
                        },
                        "pageSize": page_size
                    }
                },
                "xtype": ComponentXType.PAGINATEDSUPERGRID,
                "title": title,
                "showTitleValue": show_title_value,
            },
            "maxHeight": height if height else None,
            "parentInstanceId": parent_part_instance_id,
            "partModelId": part_model_id,
            "collapseFilters": collapse_filters
        }

        # Declare the meta info for the paginatedGrid
        meta = {
            "cloneButtonUi": "primary-action" if emphasize_clone else "defualt-toolbar",
            "cloneButtonVisible": clone,
            "primaryCloneUiValue": emphasize_clone,
            "parentInstanceId": parent_part_instance_id,
            "editButtonUi": "primary-action" if emphasize_edit else "default-toolbar",
            "editButtonVisible": edit,
            "customHeight": height if height else None,
            "primaryAddUiValue": emphasize_new_instance,
            "activityId": str(self.activity.id),
            "customTitle": title,
            "primaryEditUiValue": emphasize_edit,
            "downloadButtonVisible": export,
            "addButtonUi": "primary-action" if emphasize_new_instance else "default-toolbar",
            "deleteButtonVisible": delete,
            "addButtonVisible": new_instance,
            "showTitleValue": show_title_value,
            "partModelId": str(part_model_id),
            "showHeightValue": "Set height" if height else "Automatic height",
            "sortDirection": sort_direction,
            "sortedColumn": sort_property_id if sort_property_id else None,
            "collapseFilters": collapse_filters,
            "showCollapseFiltersValue": collapse_filters_value,
            "customPageSize": page_size
        }

        self._add_widget(dict(config=config, meta=meta, name=WidgetNames.FILTEREDGRIDWIDGET))