/**
  * Registers X-Editable plugin and the related events
  */
 protected function registerClientScript()
 {
     $view = $this->getView();
     $language = ArrayHelper::getValue($this->clientOptions, 'language');
     switch ($this->type) {
         case 'address':
             EditableAddressAsset::register($view);
             break;
         case 'combodate':
             EditableComboDateAsset::register($view);
             break;
         case 'date':
             if ($language) {
                 EditableDatePickerAsset::register($view)->js[] = 'vendor/js/locales/bootstrap-datetimepicker.' . $language . '.js';
             } else {
                 EditableDatePickerAsset::register($view);
             }
             break;
         case 'datetime':
             if ($language) {
                 EditableDateTimePickerAsset::register($view)->js[] = 'vendor/js/locales/bootstrap-datetimepicker.' . $language . '.js';
             } else {
                 EditableDateTimePickerAsset::register($view);
             }
             break;
         case 'select2':
             EditableSelect2Asset::register($view);
             break;
         case 'wysihtml5':
             $language = $language ?: 'en-US';
             EditableWysiHtml5Asset::register($view)->js[] = 'vendor/locales/bootstrap-wysihtml5.' . $language . '.js';
             break;
         default:
             EditableBootstrapAsset::register($view);
     }
     $id = ArrayHelper::remove($this->clientOptions, 'selector', '#' . $this->options['id']);
     // Escape meta-characters in element Id
     // http://api.jquery.com/category/selectors/
     // This actually only needs to be done for dots, since Html::getInputId
     // will enforce word-only characters.
     $id = preg_replace('/([.])/', '\\\\\\\\$1', $id);
     $this->clientOptions['url'] = $this->url instanceof JsExpression ? $this->url : Url::toRoute($this->url);
     $this->clientOptions['type'] = $this->type;
     $this->clientOptions['mode'] = $this->mode;
     $this->clientOptions['name'] = $this->attribute ?: $this->name;
     $pk = ArrayHelper::getValue($this->clientOptions, 'pk', $this->hasActiveRecord() ? $this->model->getPrimaryKey() : null);
     $this->clientOptions['pk'] = base64_encode(serialize($pk));
     if ($this->hasActiveRecord() && $this->model->isNewRecord) {
         $this->clientOptions['send'] = 'always';
         // send to server without pk
     }
     $options = Json::encode($this->clientOptions);
     $js = "jQuery('{$id}').editable({$options});";
     $view->registerJs($js);
     if (!empty($this->clientEvents)) {
         $js = [];
         foreach ($this->clientEvents as $event => $handler) {
             $js[] = "jQuery('{$id}').on('{$event}', {$handler});";
         }
         $view->registerJs(implode("\n", $js));
     }
 }
 /**
  * Registers required script to the columns work
  */
 protected function registerClientScript()
 {
     $view = $this->grid->getView();
     $language = $this->language;
     switch ($this->type) {
         case 'address':
             EditableAddressAsset::register($view);
             break;
         case 'combodate':
             EditableComboDateAsset::register($view);
             break;
         case 'date':
             if ($language) {
                 EditableDatePickerAsset::register($view)->js[] = 'vendor/js/locales/bootstrap-datetimepicker.' . $language . '.js';
             } else {
                 EditableDatePickerAsset::register($view);
             }
             break;
         case 'datetime':
             if ($language) {
                 EditableDateTimePickerAsset::register($view)->js[] = 'vendor/js/locales/bootstrap-datetimepicker.' . $language . '.js';
             } else {
                 EditableDateTimePickerAsset::register($view);
             }
             break;
         case 'select2':
             EditableSelect2Asset::register($view);
             break;
         case 'wysihtml5':
             $language = $language ?: 'en-US';
             EditableWysiHtml5Asset::register($view)->js[] = 'vendor/locales/bootstrap-wysihtml5.' . $language . '.js';
             break;
         default:
             EditableBootstrapAsset::register($view);
     }
     EditableColumnAsset::register($view);
     $rel = $this->options['rel'];
     $selector = "a[rel=\"{$rel}\"]";
     $grid = "#{$this->grid->id}";
     $js[] = ";jQuery('{$selector}').editable();";
     $js[] = "dosamigos.editableColumn.registerHandler('{$grid}', '{$selector}');";
     $view->registerJs(implode("\n", $js));
 }