Let a grid have custom ajax data url
i.e. instead of assuming we should GET the current "partial" page, can use a different URL altogether now
This commit is contained in:
parent
e6dff16550
commit
fd700e06f4
|
@ -74,6 +74,7 @@ class Grid(object):
|
||||||
sortable=False, sorters={}, default_sortkey=None, default_sortdir='asc',
|
sortable=False, sorters={}, default_sortkey=None, default_sortdir='asc',
|
||||||
pageable=False, default_pagesize=20, default_page=1,
|
pageable=False, default_pagesize=20, default_page=1,
|
||||||
checkboxes=False, checked=None, main_actions=[], more_actions=[], delete_speedbump=False,
|
checkboxes=False, checked=None, main_actions=[], more_actions=[], delete_speedbump=False,
|
||||||
|
ajax_data_url=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
|
|
||||||
self.key = key
|
self.key = key
|
||||||
|
@ -127,6 +128,13 @@ class Grid(object):
|
||||||
self.more_actions = more_actions or []
|
self.more_actions = more_actions or []
|
||||||
self.delete_speedbump = delete_speedbump
|
self.delete_speedbump = delete_speedbump
|
||||||
|
|
||||||
|
if ajax_data_url:
|
||||||
|
self.ajax_data_url = ajax_data_url
|
||||||
|
elif self.request:
|
||||||
|
self.ajax_data_url = self.request.current_route_url()
|
||||||
|
else:
|
||||||
|
self.ajax_data_url = ''
|
||||||
|
|
||||||
self._whgrid_kwargs = kwargs
|
self._whgrid_kwargs = kwargs
|
||||||
|
|
||||||
def make_columns(self):
|
def make_columns(self):
|
||||||
|
|
|
@ -46,7 +46,7 @@ let TailboneGrid = {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.$http.get(`?${params}`).then(({ data }) => {
|
this.$http.get(`${this.ajaxDataUrl}?${params}`).then(({ data }) => {
|
||||||
this.data = data.data
|
this.data = data.data
|
||||||
this.rowStatusMap = data.row_status_map
|
this.rowStatusMap = data.row_status_map
|
||||||
this.total = data.total_items
|
this.total = data.total_items
|
||||||
|
|
|
@ -205,6 +205,7 @@
|
||||||
loading: false,
|
loading: false,
|
||||||
checkedRows: [],
|
checkedRows: [],
|
||||||
selectedFilter: null,
|
selectedFilter: null,
|
||||||
|
ajaxDataUrl: ${json.dumps(grid.ajax_data_url)|n},
|
||||||
|
|
||||||
data: ${json.dumps(grid_data['data'])|n},
|
data: ${json.dumps(grid_data['data'])|n},
|
||||||
rowStatusMap: ${json.dumps(grid_data['row_status_map'])|n},
|
rowStatusMap: ${json.dumps(grid_data['row_status_map'])|n},
|
||||||
|
|
Loading…
Reference in a new issue