No ListView sorter if "empty" list

I have a listview with data, but some fields (inside relations) may be ‘null’ (non-existing/empty relation).

Unfortunately, unlike CGridView, CListView shows the ‘emptyText’ only and can not be told to show the list anyways (so that the sort field and other header/footer elements are show).

The limiting code is:

 public function renderSorter()	{

	 if($this->dataProvider->getItemCount()<=0 || !$this->enableSorting || empty($this->sortableAttr[size=2]ibutes)) return;[/size]<br style="font-size: 9pt;">[size=2]




[size=2]For a CGridView thsi ‘itemCountCondition’ only exists for the renderItems() method. I expected the same for the CListView class.[/size]

Sorry, but i don’t understand your question.

The implicit question is to have CListView act more liike CGridView when the resulting list is empty.

Currently when there is no data to show in a CGridView, everything is shown, except the item list.

When there is no data to show in a CListView, nothing is shown (the text says that there are no records). The sorter is not shown, the header is not shown, … .

In the Gii CRUD templates, the CListView behavior is mimiced because when the itemlist is empty, an test (if) in the generated view disables the display of the CGridView.

However, as the test is not in the CGridView, it is sufficient to remove this test and show the CGridView in all cases.

So basically what I ask is to remove the '$this->dataProvider->getItemCount()<=0 ’ test from the ‘renderSorter’ method, and possibly even from ‘renderSummary’

My use case where the current behavior is not ok is the following:

  • A list of items is presented to the end user. This list is not empty.

  • The end user clicks on a field in the sorter list to sort by that field.

  • Suddenly no more records are shown.

  • No records are shown because the field that the end user requested to sort on does not exist for his record. The field is form a relation, and for the existing records, this relation is "empty".

  • As a result the sorter, the header, etc is no longer available and hence the end user can not click to sort by another field or to undo the sorting, unless he reloads the page (luckily the sorting parameters are not remembered).

  • If the sorter and header would still be shown, then the user could simply sort on another field and see some records again.

I hope this is clear enough. If not, I have to make screen captures.