Validator form-control border color does not change for invalid input on a delegator for WTableView
Added by robs j over 3 years ago
Hello,
I am having a derived Wt::WTableView and Wt::WAbstractTableModel in Wt3.3.10
I want to validate the input on a cell. But only when hovering on the cell I can see the title="Must be a number"
but the color is not changing like in other impelementation without table e.g. dialog
The code for creation is
Wt::WWidget* DoubleDelegate::createEditor(const Wt::WModelIndex &index,
Wt::WFlagsWt::ViewItemRenderFlag flags) const
{
(void) flags;
auto const result = new Wt::WContainerWidget();
result->setSelectable(true);
auto lineEdit = new Wt::WLineEdit(result);
auto validator = new Wt::WDoubleValidator(m_bottom, m_top);
lineEdit->setValidator(validator);
lineEdit->setText(asString(index.data(Wt::EditRole), textFormat()));
lineEdit->setPlaceholderText(asString(index.data(Wt::DisplayRole), textFormat()));
lineEdit->enterPressed().connect(boost::bind(&DoubleDelegate::doCloseEditor, this, result, true));
lineEdit->escapePressed().connect(boost::bind(&DoubleDelegate::doCloseEditor, this, result, false));
lineEdit->escapePressed().preventPropagation();
if (flags & Wt::RenderFocused)
{
lineEdit->setFocus(true);
}
// We use a layout so that the line edit fills the entire cell.
// Somehow, this does not work with konqueror, but it does respond
// properly to width, height being set to 100% !
Wt::WApplication *app = Wt::WApplication::instance();
if (app->environment().agent() != Wt::WEnvironment::Konqueror)
{
result->setLayout(new Wt::WHBoxLayout());
result~~layout()>setContentsMargins(1, 1, 1, 1);layout()~~>addWidget(lineEdit);
result
}
else
{
lineEdit->resize(Wt::WLength(100, Wt::WLength::Percentage), Wt::WLength(100, Wt::WLength::Percentage));
result->addWidget(lineEdit);
}
return result;
}
and output of three rows with first row having wrong input:
2.0000
3.0000
Thanks for comments on my code.