How do I have CPagination render a no results message?

Front end dev here.

Question: I use CPagination with CGridView and filtering, when the filter returns no results no pagination information is rendered (i.e. not even the divs). Since I don’t want a section of the page appearing and disappearing, is there a way I can force it show something (like a no results message or a  ) when the filter result set is empty?

You may create own class and extend from CLinkPager class; And you should override run() function.

now


public function run()

	{

		$this->registerClientScript();

		$buttons=$this->createPageButtons();

		if(empty($buttons))

			return;

		echo $this->header;

		echo CHtml::tag('ul',$this->htmlOptions,implode("\n",$buttons));

		echo $this->footer;

	}

You may override like that:


public function run()

	{

		$this->registerClientScript();

		$buttons=$this->createPageButtons();

		if(empty($buttons))

			echo "<p>No results found.</p>";

		echo $this->header;

		echo CHtml::tag('ul',$this->htmlOptions,implode("\n",$buttons));

		echo $this->footer;

	}