From 78213544fdcdb14dfd8326aaee18fc04139fcaa8 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 17 Nov 2020 10:56:41 +0800 Subject: [PATCH] bugfix --- kivyblocks/dg.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kivyblocks/dg.py b/kivyblocks/dg.py index 990f1d5..d2997e5 100644 --- a/kivyblocks/dg.py +++ b/kivyblocks/dg.py @@ -251,6 +251,15 @@ class DataGrid(WidgetReady, BoxLayout): self.loading = False self.freeze_fields = self.getPartFields(freeze_flag=True) self.normal_fields = self.getPartFields(freeze_flag=False) + ldr_desc = options.get('dataloader') + if not ldr_desc: + raise Exception('DataGrid need a DataLoader') + self.dataloader = RelatedLoader(target=self, **ldr_desc) + self.dataloader.bind(on_deletepage=self.delete_page) + self.dataloader.bind(on_pageloaded=self.add_page) + self.dataloader.bind(on_newbegin=self.clearRows) + self.register_event_type('on_selected') + self.register_event_type('on_scrollstop') self.createDataGridPart() self.createToolbar() if self.toolbar: @@ -262,15 +271,6 @@ class DataGrid(WidgetReady, BoxLayout): if self.normal_part: b.add_widget(self.normal_part) self.add_widget(b) - ldr_desc = options.get('dataloader') - if not ldr_desc: - raise Exception('DataGrid need a DataLoader') - self.dataloader = RelatedLoader(target=self, **ldr_desc) - self.dataloader.bind(on_deletepage=self.delete_page) - self.dataloader.bind(on_pageloaded=self.add_page) - self.dataloader.bind(on_newbegin=self.clearRows) - self.register_event_type('on_selected') - self.register_event_type('on_scrollstop') def locater(self,pos): self.normal_part.body.scroll_y = pos