From f90862c627f94c21bdf33e1982c702677a977d83 Mon Sep 17 00:00:00 2001 From: Jim Steil Date: Thu, 16 May 2024 01:38:03 -0500 Subject: [PATCH] allow lambda on td_class_style on Column (#865) --- py4web/utils/grid.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/py4web/utils/grid.py b/py4web/utils/grid.py index f1ac8ac5a..c50cc946e 100644 --- a/py4web/utils/grid.py +++ b/py4web/utils/grid.py @@ -8,8 +8,25 @@ from urllib.parse import urlparse from pydal.objects import Expression, Field, FieldVirtual -from yatl.helpers import (CAT, DIV, FORM, INPUT, OPTION, SELECT, SPAN, TABLE, - TAG, TBODY, TD, TH, THEAD, TR, XML, A, I) +from yatl.helpers import ( + CAT, + DIV, + FORM, + INPUT, + OPTION, + SELECT, + SPAN, + TABLE, + TAG, + TBODY, + TD, + TH, + THEAD, + TR, + XML, + A, + I, +) from py4web import HTTP, URL, redirect, request, safely from py4web.utils.form import Form, FormStyleDefault, join_classes @@ -1201,11 +1218,15 @@ def _make_table_body(self): elif isinstance(column, Column): classes = self.param.grid_class_style.classes.get( column.td_class_style, - self.param.grid_class_style.classes.get("grid-td"), + column.td_class_style(row) + if callable(column.td_class_style) + else self.param.grid_class_style.classes.get("grid-td"), ) style = self.param.grid_class_style.styles.get( column.td_class_style, - self.param.grid_class_style.styles.get("grid-td"), + column.td_class_style(row) + if callable(column.td_class_style) + else self.param.grid_class_style.styles.get("grid-td"), ) tr.append( TD(