Problem with CTreeView on mode prerendered = true

Problem is when the prerendered option is set.

I add checking that the current node’s index is the last and when is I add to css class name word ‘last’.


public static function saveDataAsHtml($data) {

		$html = '';

		if (is_array($data)) {

			$dataSize = count($data);

			$index = 1;

			foreach ($data as $node) {

				if (!isset($node['text']))

					continue;

				$id = isset($node['id']) ? (' id="' . $node['id'] . '"') : '';

				if (isset($node['expanded']))

					$css = $node['expanded'] ? 'open' : 'closed';

				else

					$css='';

				if (isset($node['hasChildren']) && $node['hasChildren']) {

					if ($css !== '')

						$css.=' ';

					$css.='hasChildren';

				}

				if ($index == $dataSize) {

					$css .= ' last';

				}

				if ($css !== '')

					$css = ' class="' . $css . '"';

				$html.="<li{$id}{$css}>{$node['text']}";

				if (!empty($node['children'])) {

					$html.="\n<ul>\n";

					$html.=self::saveDataAsHtml($node['children']);

					$html.="</ul>\n";

				}

				$html.="</li>\n";

				$index++;

			}

		}

		return $html;

	}