Forum
Sign Up
× DataGrid for Qt.C++

setting up filters programmatically to a view

9 years 9 months ago #1 by corrado valeri
How to setting programmatically different filters to a Qtitan::Grid::TableView column?
In the documentation there is only a filter descriptions end-user side.
thanks

Please Log in or Create an account to join the conversation.

More
9 years 9 months ago #2 by corrado valeri
twenty days without an answer, why?

Please Log in or Create an account to join the conversation.

More
9 years 9 months ago #3 by Developer Machines
I apologize for the delay. We are currently working on porting QtitanDataGrid (and other components) to Qt5 and doing a pilot Grid project for Firemonkey (Delphi).
Therefore not always have time to respond quickly. I ask you to duplicate your bugreports to the This email address is being protected from spambots. You need JavaScript enabled to view it. too.

About filters. Grid view has a function GridFilter* GridViewBase::filter() const;
It's used to make a user specific filters for grid data. All you need is to create a filter condition (GridFilterValueCondition and GridFilterGroupCondition classes) programmatically (that you want) and install it in the filter object.
Furthermore you can get access to the history of filter's conditions using - GridFilterHistory* GridFilter::history() const;

Please Log in or Create an account to join the conversation.

More
9 years 7 months ago #4 by corrado valeri
Hello, I tried but doesn't works.
Would you like help me to solve this problem?
Here's the code I wrote:
Qtitan::GridTableView* view_titan_grid = ui->titanGridFilteredWagons->view<Qtitan::GridTableView>();
    GridFilter * flt = view_titan_grid->filter();
    GridFilterGroupCondition * groupCond = new GridFilterGroupCondition(flt);
    GridFilterValueCondition * valueCond = new GridFilterValueCondition(flt);
    QString espressione="'LIB./AGG.' = 'LIBERO'";
    valueCond->addValue(espressione);
    groupCond->addValue(valueCond);
    flt->setCondition(groupCond);
    flt->setActive(true);

I want to setup the filter as shown in the picture attached to this post.
I read the whole documentation but there is no explanation about filters.
thanxs
Attachments:

Please Log in or Create an account to join the conversation.

More
9 years 7 months ago #5 by Developer Machines
Please try this code:

Qtitan::GridTableView* view = m_grid->view<Qtitan::GridTableView>();

view->showFilterPanel();

GridFilter * flt = view->filter();
GridFilterGroupCondition * groupCond = new GridFilterGroupCondition(flt);
GridFilterValueCondition * valueCond = new GridFilterValueCondition(flt);
Qtitan::GridTableColumn* column = (Qtitan::GridTableColumn *)view->getColumnByModelColumnName("LIB./AGG.");
valueCond->setModelColumn(column->dataBinding()->column()); //For this column filer will be applyed - param is a index in your Qt model.
valueCond->setModelRole(Qt::DisplayRole); //By default is Qt:DisplayRole
valueCond->setValueOperator(GridFilterCondition::FilterEqual); //Operation for comparing
QString espressione = "LIBERO";
valueCond->addValue(espressione);
groupCond->addValue(valueCond); //Group can hold more than one value of condition.
flt->setCondition(groupCond);
flt->setActive(true);

Please Log in or Create an account to join the conversation.

More
9 years 7 months ago #6 by corrado valeri
It worked perfectly: thanks :)

Please Log in or Create an account to join the conversation.

More
  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Moderators: Developer Machines
Time to create page: 0.335 seconds

Developer Newsletter

Join our Developer Machines newsletter to get informed on all the latest releases of the commercial components for Qt.C++, Delphi FireMonkey, updates and general knowledges.

Quick Support

Should you need any additional information about our products or licensing, please contact us at the following email addresses:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

Get in Touch

If you would like to purchase our products or services, but don’t know how to do it the right way, please feel free to contact us:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.( any questions related to our products or services )
  • This email address is being protected from spambots. You need JavaScript enabled to view it.( questions related to licensing )