Forum
Sign Up
× DataGrid for Qt.C++

How select a row in GridBandedTableView?

9 years 2 weeks ago #1 by Andrey Florinsky
Hi, guys!
The problem with this:
I get a real ModelIndex row of element:
int row = m_view->focusedRow()->modelRowIndex();

Now I do sorting or filtering or grouping in view.
And then I want to focus this row.

How can I do this?
m_view->setFocusedRowIndex(row)
Is not working properly.

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

More
9 years 2 weeks ago - 9 years 2 weeks ago #2 by Developer Machines
To do that please use the following code:
    Qtitan::GridTableView* view = m_grid->view<Qtitan::GridTableView>();
    int modelRowIndex = view->focusedRow()->modelRowIndex();
    //.... sorting, grouping
    GridRow* row = view->getRow(view->model()->index(modelRowIndex, 0));
    if (row != 0)
        view->setFocusedRowIndex(row->rowIndex());

It seems that we need to add several new routines of working with a row focus for the convenience.
Last edit: 9 years 2 weeks ago by Developer Machines.
The following user(s) said Thank You: Andrey Florinsky

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

More
9 years 2 weeks ago - 9 years 2 weeks ago #3 by Andrey Florinsky
Thank you very much, it looks like it works.
Now, if a group is collapsed, the group row is focused (not the element), I would like to expand the Group.
GridRow* parentGroupRow = row->parentGroupRow();
if (parentGroupRow != 0)
    parentGroupRow->setExpanded(true);
Is not working properly. Help me, please, how to make correctly?
Thank you.
Last edit: 9 years 2 weeks ago by Andrey Florinsky.

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

More
9 years 2 weeks ago #4 by Developer Machines
In this case you do not need to get a parent group row (you already have a reference to group row that is focused). Just use row->setExpanded(true).

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.143 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 )