diff --git a/plexpy/helpers.py b/plexpy/helpers.py index 6699e1e3..af761e05 100644 --- a/plexpy/helpers.py +++ b/plexpy/helpers.py @@ -768,13 +768,13 @@ def build_datatables_json(kwargs, dt_columns, default_sort_col=None): # Build json data json_data = {"draw": 1, - "columns": columns, - "order": [{"column": order_column, + "columns": columns, + "order": [{"column": order_column, "dir": kwargs.pop("order_dir", "desc")}], - "start": int(kwargs.pop("start", 0)), - "length": int(kwargs.pop("length", 25)), - "search": {"value": kwargs.pop("search", "")} - } + "start": int(kwargs.pop("start", 0)), + "length": int(kwargs.pop("length", 25)), + "search": {"value": kwargs.pop("search", "")} + } return json.dumps(json_data) def humanFileSize(bytes, si=False): diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 61c14875..fd6e9b84 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -665,9 +665,13 @@ class WebInterface(object): # Check if datatables json_data was received. # If not, then build the minimal amount of json data for a query if not kwargs.get('json_data'): + # Alias 'title' to 'sort_title' + if kwargs.get('order_column') == 'title': + kwargs['order_column'] == 'sort_title' + # TODO: Find some one way to automatically get the columns dt_columns = [("added_at", True, False), - ("title", True, True), + ("sort_title", True, True), ("container", True, True), ("bitrate", True, True), ("video_codec", True, True), @@ -678,7 +682,7 @@ class WebInterface(object): ("file_size", True, False), ("last_played", True, False), ("play_count", True, False)] - kwargs['json_data'] = build_datatables_json(kwargs, dt_columns, "title") + kwargs['json_data'] = build_datatables_json(kwargs, dt_columns, "sort_title") if refresh == 'true': refresh = True