That generally doesn’t answer the question, in my opinion. So what, that I can count all data rows passed to CGridView data provider? With what parameter I should compare this number? Citing documentation:
gives us that there is now way to get to data provider in expression evaluated per each row.
So the question remains open. How to display particular button for all rows except last one? What expression should be used for visible parameter?
And speaking about total number of rows. Does CGridView.summaryText takes CActiveDataProvider->criteria->condition into consideration? For me it seems that non. I have 15 records in one of my tables, and one of them has del column > 0. When I passed CActiveDataProvider with criteria set to CDbCriteria>condition = ‘del = 0’; I got summary text saying: “Positions 1-14. Total count: 15.” (or something similar, as I’m translating Polish message into English".
Of course I have only fourteen records in CGridView and no pager, as in fact there are only fourteen, not fifteen total records.
Attribute CGridView.summaryText was not modified by my in anyway. It displays default text. And pagination component of CActiveDataProvider is set to ‘pagination’=>array(‘pageSize’=>20), so there is now way that last records is on some other page. It simply looks like summaryText gives incorrect record count.
Did you finally find an expression for determining the last row of a CGridView?
I am implementing some functionality where the user can sort rows up and down and I am providing UP and DOWN action buttons. Obviously I do not want to display a DOWN button on the last row. Hiding the UP button on the first row is easy (‘visible’ => ‘$row != 0’) as you said.
But I am stuck displaying a DOWN button on the last row (that, when clicked, does nothing)
Nope! I dropped, it leaving as you told – having down button also in last row (and even up button in first! :], that do nothing for this row. Because client, for which I was developing that application told me, that this is not a problem at all for him, and that he even prefer version with all (four) buttons in every row, for visual reasons.
Later, thinking about it, I found only one solution, that you might consider – purely jQuery one. Give your “down” buttons a special class, then select using jQuery all of them (all objects having that class), find the last one in selected range and hide it, using .css(‘display’, ‘none’). Should work…