Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text Formatting for the Columns? #49

Open
jasonflaherty opened this issue Oct 31, 2023 · 2 comments
Open

Text Formatting for the Columns? #49

jasonflaherty opened this issue Oct 31, 2023 · 2 comments

Comments

@jasonflaherty
Copy link

Excellent library. Thanks for the hard work!

I'm looking for a way to bold or italicize text in one of the columns. Am I missing something or is this not something that can be done at this time?

@apgapg
Copy link
Owner

apgapg commented Nov 1, 2023

You can use tablecellBUilder function to customize a cell widget

@jasonflaherty
Copy link
Author

jasonflaherty commented Nov 1, 2023

I am using a small amount of data, so was able to use .contains(x) on a list; however, on larger datasets, do you have a thought on how to identify a column alone vs each value in the columns?

I was thinking of an extra parameter in here for example:

JsonTableColumn("DOB", label: "Date of Birth", valueBuilder: formatDOB, columnFormatting: formatColumn1),

Here is what I did:

var botanicalNames = ['Baikiaea plurijuga', 'Pterocarpus angolensis', 'Guibourtia coleosperma', 'Afzelia quanzensis', 'Colophospermum mopane', 'Erythrophleum africanum', 'Brachystegia spiciformis', 'Julbernardia paniculata', 'None', 'Burkea africana', 'Terminalia sericea', 'Pterocarpus tinctorius', 'Kirkia acuminata'];
return JsonTable(
 timberdata,
 tableCellBuilder: (value) {
     if (botanicalNames.contains(value)) {
       return Container(
         padding: EdgeInsets.symmetric(horizontal: 4.0, vertical: 2.0),
         decoration: BoxDecoration(border: Border.all(width: 0.5, color: Colors.grey.withOpacity(0.5))),
         child: Text(
           value,
           textAlign: TextAlign.left,
           style: TextStyle(fontStyle: FontStyle.italic),
         ),
       );
     } else {
       return Container(
         padding: EdgeInsets.symmetric(horizontal: 4.0, vertical: 2.0),
         decoration: BoxDecoration(border: Border.all(width: 0.5, color: Colors.grey.withOpacity(0.5))),
         child: Text(
           value,
           textAlign: TextAlign.left,
           style: TextStyle(fontStyle: FontStyle.normal),
         ),
       );
     }
 },
 columns: columns,
 allowRowHighlight: true,
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants