Questions about actions in qdatagrid and problems with paginator

Login or register to post comments
3 replies [Last post]
Offline
Joined: 02/04/2011

Hi! I have a questions about QDatagrid and I hope that someone help me.

I have a Qdatagrid with a qpaginator and a qcheckboxcolumn that show information about 'clients'. Every checkbox's row has his event click (this action show or hide a qpanel) and the checkbox from the header(select all) has other action, I can controll it with qdatagrid->AddAction.

*The first problem is that I need have a link to the client. I've tried to do when I create the rows with a function to do the name of the client as a link (HtmlEntities =false) but the problem is that page shows error because it has to do 2 things, the row action and go to the direction's link.

*Other problem is that if I 'delete' or no show some records in the datagrid (the qpanel that checkbox show has the options to 'delete' records in DB, really change the state of clients, isn't a real delete) and then refresh the datagrid,the paginator doesn't run correctly, how I can do it better?Is possible that doesn't run because datagrid->TotalItemCount are wrong? I try it with 2 options-> 1/totalItemCount=Clients::CountAll() and 2/totalItemCount=Clients::QueryCount(...query...)

*Other questions, is possible to 'clean' the array that contain the selected items in qcheckboxcolumn (column->GetSelectedIds())

Thanks a lot and if someone can help me I'm greateful

Offline
Joined: 04/22/2009

Hello,

Problem 1:
I think there is just too much going on in your datagrid. I would recommend creating a controlproxy for showing your panel rather than a row action.

Problem 2:
How do you refresh your datagrid? Are you doing it in Form_PreRender?

Cheers

Helge

Offline
Joined: 02/04/2011

First I grateful to read your answer,
second,could you help me to add a qcontrolproxy in my qdatagrid correctly,
just a few notes, when I read your post I've seen the exemple about it, but
in this exemple, in the template page render are the controlproxy with the
action, it's possible to do it in php page? how can add a controlproxy in a
datagrid to do actions when I click in datagrid, some rows or the links that
datagrid shows.

The other problem, I say 'yes', I refresh it in preRender, I'm not sure if
the problem are because I don't know if the datagrid->totalItemCount in
function datagrind_bind are correctly. there I have querycount function and
when I go to next page, the paginator can't show the option 'previous' and
'next'.

sp
Offline
Joined: 05/20/2011

Its hard to say without code, so I will give a generalized answer. For paginators, there are some things you have to keep in mind:

1) The item count has to be correct. You said that your delete is really just a status change. I assume you are saying you then hide that row somehow. You need to make sure your queries are correctly reflecting the number of items you want to show, not just the total number of items in the db. If you are filtering the list, be sure you filter before you count the items. Your best bet here is to debug with a small set of sample code. Go to the effort of setting up xdebug or something like that so you can single step through your bind function.

2) Make sure you are on the right page. In other words, if you are viewing page 2, and then you change something so that only one page of data is showing, you will see some strange things in the paginator. In this case, you would set the page number back to 1, or whatever you compute the total number of pages to be. Depends what you want.

3) I don't know about refreshing in the pre-render. I have never had to do that. I just refresh after I do something in Ajax that might change the datagrid. The framework has always taken care of things after that. As above though, if what you do changes the page count, you might have to manually change the page number of the paginator. That will not happen automatically with a refresh.