Project

General

Profile

WTableView ItemDataRole::Link

Added by Maximilian Kleinert almost 5 years ago

Hi,

I want to make a link to a resource in a cell of a WTableView. Therefore I specialized the model (in this case Wt::Dbo::QueryModel) and overrided the data method:

Wt::cpp17::any data(const Wt::WModelIndex &index, Wt::ItemDataRole role) const override {
...
if (role == Wt::ItemDataRole::Link)
{
    return Wt::WLink(std::make_shared<Resource>(...));
}
...
}

For other roles I am calling the base method.

It works but for these cells the alternating row feature is not working any more. Another option would be to handle the click event, get the desired data out of the model, create the resource and provide a download to the user. But how can I provide a download to the user from an event?

Thank you.

Best regards

Max