78 if (empty($this->url))
79 $this->url = Yii::app()->getRequest()->requestUri;
81 $this->registerClientScript();
93 $data = $this->grid->dataProvider->data[$row];
94 $options = $this->htmlOptions;
96 if ($this->cssClassExpression !== null) {
97 $class = $this->evaluateExpression($this->cssClassExpression, array(
'row' => $row,
'data' =>
$data));
98 if (isset($options[
'class'])) {
99 $options[
'class'] .=
' ' .
$class;
101 $options[
'class'] =
$class;
105 echo CHtml::openTag(
'td', $options);
106 echo CHtml::openTag(
'span', array(
'class' => $this->cssClass,
'data-rowid' => $this->
getPrimaryKey(
$data)));
107 $this->renderDataCellContent($row,
$data);
108 echo CHtml::closeTag(
'span');
109 echo CHtml::closeTag(
'td');
122 if ($this->grid->dataProvider instanceof CActiveDataProvider) {
123 $key = $this->grid->dataProvider->keyAttribute === null ?
$data->getPrimaryKey()
124 :
$data->{$this->grid->dataProvider->keyAttribute};
125 return is_array($key) ? implode(
'--', $key) : $key;
128 if ($this->grid->dataProvider instanceof CArrayDataProvider || $this->grid->dataProvider instanceof CSqlDataProvider) {
129 return is_object(
$data) ?
$data->{$this->grid->dataProvider->keyField}
130 :
$data[$this->grid->dataProvider->keyField];
139 public function registerClientScript() {
144 $cs = Yii::app()->getClientScript();
145 if ($this->afterAjaxUpdate !== null) {
146 if ((!$this->afterAjaxUpdate instanceof CJavaScriptExpression)
147 && (strpos($this->afterAjaxUpdate,
'js:') !== 0)
149 $this->afterAjaxUpdate =
new CJavaScriptExpression($this->afterAjaxUpdate);
152 $this->afterAjaxUpdate =
'js:$.noop';
155 $this->ajaxErrorMessage = CHtml::encode($this->ajaxErrorMessage);
156 $afterAjaxUpdate = CJavaScript::encode($this->afterAjaxUpdate);
157 $span = count($this->grid->columns);
159 $cache = $this->cacheData ?
'true' :
'false';
160 $data = !empty($this->submitData) && is_array($this->submitData) ? $this->submitData :
'js:{}';
162 list($parentId) = explode(
'_',$this->
id);
164 $(document).on(
'click',
'#{$parentId} .{$this->cssClass}',
function(){
167 var status = that.data(
'status');
168 var rowid = that.data(
'rowid');
169 var tr = $(
'#relatedinfo'+rowid);
170 var parent = that.parents(
'tr').eq(0);
171 var afterAjaxUpdate = {$afterAjaxUpdate};
173 if (status && status==
'on'){
return}
174 that.data(
'status',
'on');
176 if (tr.length && !tr.is(
':visible') && {$cache})
179 that.data(
'status',
'off');
181 }
else if (tr.length && tr.is(
':visible'))
184 that.data(
'status',
'off');
189 tr.find(
'td').html(
'{$loadingPic}');
190 if (!tr.is(
':visible')){
196 var td = $(
'<td/>').html(
'{$loadingPic}').attr({
'colspan':$span});
197 tr = $(
'<tr/>').prop({
'id':
'relatedinfo'+rowid}).append(td);
199 var fake = $(
'<tr class="hide"/>').append($(
'<td/>').attr({
'colspan':$span}));
203 var data = $.extend({
$data}, {
id:rowid});
207 success:
function(data){
208 tr.find(
'td').html(data);
209 that.data(
'status',
'off');
210 if ($.isFunction(afterAjaxUpdate))
212 afterAjaxUpdate(tr,rowid,data);
217 tr.find(
'td').html(
'{$this->ajaxErrorMessage}');
218 that.data(
'status',
'off');
223 $cs->registerScript(__CLASS__ .
'#' . $this->
id, $js);