Project

General

Profile

Actions

Bug #5145

closed

Non linear comboBox

Added by Marko Taht almost 8 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
07/28/2016
Due date:
% Done:

0%

Estimated time:

Description

IS there a way to make combobox nonlinear in Wt or do i have to make my own combobox(select)? Currently calues are moving 0, 1, 2 ... I would like to repalce them whit some other values. I have a Db table with names, i want to make the values as the ID in database, and then i can use the ID-s from combobox to search DB for other stuff that are connected to the name.

Actions #1

Updated by Wim Dumon almost 8 years ago

  • Status changed from New to Resolved

Hey,

I usually use WComboBox in combination with a model in order to have a direct link between the selected index and the object it represents. Combined with Dbo, you can use the Wt::Dbo::QueryModel to link the result of a Db query directly to a combobox. See WComboBox::setModel(), WComboBox::setModelColumn().

Wim.

Actions #2

Updated by Marko Taht almost 8 years ago

What about the empty selection? When using Standrt item model i can add empty selection but when takeing data from database how do i add empty selection? setData does not want to work, setCurrentIndex --1 does not what i want.

Actions #3

Updated by Wim Dumon almost 8 years ago

Did you call WComboBox:: setNoSelectionEnabled()?

Wim.

Actions #4

Updated by Marko Taht almost 8 years ago

I tryed still always defaults to first element. Nomatter where i put it or what i comment out, nothing changes.

Wt::WComboBox *authorCB = new Wt::WComboBox();

authorCB~~setModel(model~~>authorModel());

authorCB->setNoSelectionEnabled(true);

setFormWidget(AddAlbumFormModel::AutorField, authorCB,

[=]() {

std::string code = boost::any_caststd::string

(model->value(AddAlbumFormModel::AutorField));

int row = model->authorModelRow(code);

authorCB->setCurrentIndex(row);

},

[=]() {

std::string code = model~~authorCode(authorCB~~>currentIndex());

model->setValue(AddAlbumFormModel::AutorField, code);

});

Actions #5

Updated by Marko Taht almost 8 years ago

Ok i got it. I had to setNoSelwctionnabled before setting the model.

Actions #6

Updated by Roel Standaert about 7 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF