##// END OF EJS Templates
base-grid-view: allow specifing custom mapping for sort columns.
marcink -
r1649:1c00b1d7 default
parent child Browse files
Show More
@@ -135,7 +135,8 b' class DataGridAppView(object):'
135 Common class to have re-usable grid rendering components
135 Common class to have re-usable grid rendering components
136 """
136 """
137
137
138 def _extract_ordering(self, request):
138 def _extract_ordering(self, request, column_map=None):
139 column_map = column_map or {}
139 column_index = safe_int(request.GET.get('order[0][column]'))
140 column_index = safe_int(request.GET.get('order[0][column]'))
140 order_dir = request.GET.get(
141 order_dir = request.GET.get(
141 'order[0][dir]', 'desc')
142 'order[0][dir]', 'desc')
@@ -143,10 +144,7 b' class DataGridAppView(object):'
143 'columns[%s][data][sort]' % column_index, 'name_raw')
144 'columns[%s][data][sort]' % column_index, 'name_raw')
144
145
145 # translate datatable to DB columns
146 # translate datatable to DB columns
146 order_by = {
147 order_by = column_map.get(order_by) or order_by
147 'first_name': 'name',
148 'last_name': 'lastname',
149 }.get(order_by) or order_by
150
148
151 search_q = request.GET.get('search[value]')
149 search_q = request.GET.get('search[value]')
152 return search_q, order_by, order_dir
150 return search_q, order_by, order_dir
General Comments 0
You need to be logged in to leave comments. Login now