column cell with link
Is it possible to have in flutter grid a cell with link to open the browser ? or a button to open a link
SIGN IN To post a reply.
4 Replies
RS
Renugadevi Sadagoban
Syncfusion Team
August 12, 2021 12:55 PM UTC
Hi Stefan,
Thanks for contacting syncfusion support.
The SfDataGrid provides support for load any type of widget in each column. So here we have wrapped a GestureDetector inside the Container widget for the Link column alone. When you tap the cell, the given URL will be opened in browser using onTap callback of GestureDetector.
Refer the following code snippet,
|
@override
DataGridRowAdapter buildRow(DataGridRow row) {
return DataGridRowAdapter(
cells: row.getCells().map<Widget>((e) {
return e.columnName == "link"
? Container(
alignment: Alignment.center,
padding: EdgeInsets.all(8.0),
child: GestureDetector(
onTap: () => _launchURL(e.value),
child: Text(
'Link',
overflow: TextOverflow.ellipsis,
style: TextStyle(
decoration: TextDecoration.underline, color: Colors.blue),
),
))
: Container(
alignment: Alignment.center,
padding: EdgeInsets.all(8.0),
child: Text(
e.value.toString(),
overflow: TextOverflow.ellipsis,
));
}).toList());
}
_launchURL(String hyperlink) async {
if (await canLaunch(hyperlink)) {
await launch(hyperlink);
} else {
throw 'Could not launch $hyperlink';
}
} |
And, Refer the following sample for your reference,
Please let us know if need any further assistance.
Regards,
Renugadevi
ST
Steven Tillson
August 14, 2021 10:49 AM UTC
Container(
alignment: Alignment.center,
padding: EdgeInsets.all(8.0),
child: Text(
e.value.toString(),
overflow: TextOverflow.ellipsis,
));
}).toList());
You can skip it i think?
RS
Renugadevi Sadagoban
Syncfusion Team
August 16, 2021 07:15 AM UTC
Hi Stefan,
Thanks for your update.
In the provided sample, we have given hyperlinks for the link column alone. We have loaded the Container widget for other columns except the hyperlink column.
Refer the following image,
We couldn’t clearly understand your requirement. Can you please provide more details about your requirement? It would be helpful for us to provide the solution.
Regards,
Renugadevi.
ST
Stefan Tsalapatis
August 16, 2021 08:22 AM UTC
Hi Renugadevi,
That I wanted. Thanks Steven asked something else relevant.
Can the hyperlink column render an icon?
Stefan
SIGN IN To post a reply.
- 4 Replies
- 3 Participants
-
ST Stefan Tsalapatis
- Aug 11, 2021 07:32 PM UTC
- Aug 16, 2021 08:22 AM UTC