Project

General

Profile

Actions

Bug #1897

closed

Combo box findText and setValueText

Added by Ariel Kruger almost 11 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
05/06/2013
Due date:
% Done:

0%

Estimated time:

Description

I am trying to use the methods findText and setValueText,

but I just get it working when adding the itens manually.

  WComboBox *cb = new WComboBox();
  ariel->addItem("text");
  std::cout << "\nitem = " << cb->findText("text") << std::endl;

but When I am using a QueryModel

typedef boost::tuple<int,std::string> comboResult;

categoriaModel_ = new Wt::Dbo::QueryModel<comboResult>();
categoriaModel_->addAllFieldsAsColumns();
categoriaModel_->setQuery(session_.query<comboResult>("select id_categoria, nm_categoria from geral.categoria_produto union select 0, '' order by nm_categoria"));

combo = new Wt::WComboBox();
combo->setModel(model);
combo->setModelColumn(1);

using a QueryModel when try to use combo->findText("text"); it doen't work...

Actions #1

Updated by Ariel Kruger almost 11 years ago

I just got it working with a extra code

                for(int i = 0; i < combo->count(); i ++){
                    if(combo->itemText(i) == value)
                        combo->setCurrentIndex(i);
                }
Actions #2

Updated by Koen Deforche almost 11 years ago

  • Status changed from New to Resolved
  • Assignee set to Koen Deforche
  • Target version set to 3.3.1

Hey,

This is probably because your model isn't containing WString but string data. The default flags include MatchExactly which also checks that the types are the same.

I've implemented now an exception for std::string and WString since they can be compared exactly (and this will cause one surprise less).

Regards,

koen

Actions #3

Updated by Koen Deforche over 10 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF