Skip to content

Commit

Permalink
feat: add support to clear empty grid label
Browse files Browse the repository at this point in the history
Close #103
  • Loading branch information
flang committed Dec 11, 2023
1 parent 2972aab commit 6ef1e85
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ void setEmptyGridLabel(Component component) {

emptyLabel = component;

if (registration != null) {
registration.remove();
registration = null;
}
removeRegistration();

if (component != null) {
DataProviderListener listener =
Expand All @@ -69,4 +66,19 @@ void setEmptyGridLabel(Component component) {
Component getEmptyGridLabel() {
return emptyLabel;
}

void clearEmptyGridLabel() {
if (emptyLabel != null) {
emptyLabel.setVisible(false);
}
emptyLabel = null;
removeRegistration();
}

private void removeRegistration() {
if (registration != null) {
registration.remove();
registration = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ public static void setEmptyGridLabel(Grid<?> grid, Component component) {
getHelper(grid).emptyLabel.setEmptyGridLabel(component);
}

/** Clears the component that is displayed when the Grid would show an empty data set. */
public static void clearEmptyGridLabel(Grid<?> grid) {
getHelper(grid).emptyLabel.clearEmptyGridLabel();
}

/** Returns the component that is displayed when the Grid would show an empty data set. */
public static Component getEmptyGridLabel(Grid<?> grid) {
return getHelper(grid).emptyLabel.getEmptyGridLabel();
Expand Down

0 comments on commit 6ef1e85

Please sign in to comment.