Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Setting emptytext for editableColumn not possible #127

Closed
surfer190 opened this issue Dec 22, 2014 · 10 comments
Closed

Setting emptytext for editableColumn not possible #127

surfer190 opened this issue Dec 22, 2014 · 10 comments

Comments

@surfer190
Copy link

Is setting emptytext for editableColumn possible?

I see it in the docs with "Click to Edit" but it seems using an override:

if($.fn.editable) $.extend($.fn.editable.defaults, {'emptytext':'Click to edit','mode':'popup'});

@ybreeze
Copy link

ybreeze commented Dec 22, 2014

It's possible to overwrite, just add 'emptytext' to X-editable plugin options -

         array( 
            'class' => 'editable.EditableColumn',
            'name' => 'virtual_field',
            'value' => 'CHtml::value($data, "profile.language")',
            'editable' => array(
                'emptytext' => 'Some text here',
                'type' => 'text',
                'attribute' => 'profile.language',
                'url' => $this->createUrl('site/updateProfile'),
                'placement' => 'left',
            )
        ), 

@surfer190
Copy link
Author

What I have:

array( 
              'class' => 'editable.EditableColumn',
              'name' => 'ad_n',
              'header' => 'Add. Neg. Breakout',
              'editable' => array(
                  'type' => 'text',
                  'url'      => $this->createUrl('ajax/updateWtch'),
                  'placement' => 'right',
                  'emptytext'  => 'no value',
              ),
         ),

The column shows:

-

Then when you click to edit, it has a single space in text box.

@Julian-B90
Copy link
Collaborator

Try this

$this->widget('editable.EditableDetailView', array(
    'data' => $model,
    'emptytext' => 'no value',
    'attributes' => array(
        array(
            'name' => 'ad_n',
            'header' => 'Add. Neg. Breakout',
            'editable' => array(
                'type' => 'text',
                'url' => $this->createUrl('ajax/updateWtch'),
                'placement' => 'right',
            ),
        ),
    )
));

@surfer190
Copy link
Author

@Julian-B90 So forced to use a listview, as will not work with:

<? $this->widget('bootstrap.widgets.TbGridView', array(...

@Julian-B90 Julian-B90 reopened this Dec 23, 2014
@Julian-B90
Copy link
Collaborator

bootstrap.widgets.TbGridView.

supports the 'emptyText' property because it extendet from the CGriedView

@surfer190
Copy link
Author

I get: Property "TbGridView.emptytext" is not defined

The full code:

<?php $this->widget('bootstrap.widgets.TbGridView', array(
    'id' => 'wtchgrid',
    'itemsCssClass' => 'table-bordered items',
    'dataProvider' => $watchData,
    'emptytext' => 'no value',
    'columns'=>array(
         ...
         array( 
              'class' => 'editable.EditableColumn',
              'name' => 'ad_n',
              'header' => 'Add. Neg. Breakout',
              'editable' => array(
                  'url'      => $this->createUrl('site/updateWtch'),
                  'placement' => 'right',
              ),
         ),
         ...
    ),
)); 

@Julian-B90
Copy link
Collaborator

maybe

<?php $this->widget('bootstrap.widgets.TbGridView', array(
    'id' => 'wtchgrid',
    'itemsCssClass' => 'table-bordered items',
    'dataProvider' => $watchData,
    'blankDisplay' => 'no Value',
    'nullDisplay' => 'no Value',
    'columns'=>array(
         ...
         array( 
              'class' => 'editable.EditableColumn',
              'name' => 'ad_n',
              'header' => 'Add. Neg. Breakout',
              'editable' => array(
                  'url'      => $this->createUrl('site/updateWtch'),
                  'placement' => 'right',
              ),
         ),
         ...
    ),
)); 

@surfer190
Copy link
Author

@Julian-B90 Thanks.

When I use: 'nullDisplay' => 'no Value',
The editable editbox actually contains no Value.
Label is no Value

However if I use: 'nullDisplay' => '',
The editable editbox, contains nothing.
Label is Click to Edit

@Julian-B90
Copy link
Collaborator

ok now i remeber for the right solution.

<?php

class TestModule extends CWebModule
{   
    public function init() 
    {
        // this method is called when the module is being created
        // you may place code here to customize the module or the application

        //assume you unzipped extension under protected/extensions/x-editable
        Yii::setPathOfAlias('editable', Yii::getPathOfAlias('ext.x-editable.*'));

        // import the module-level models and components
        $this->setImport(array(
            'test.models.*',
            'test.components.*',
            'editable.*'
        ));

        $component = Yii::createComponent(array(
                'class'     => 'editable.EditableConfig',
                'form'      => 'bootstrap',        //form style: 'bootstrap', 'jqueryui', 'plain' 
                'mode'      => 'popup',            //mode: 'popup' or 'inline'  
                'defaults'  => array(              //default settings for all editable elements
                   'emptytext' => 'Click to edit'
                )
        ));

        Yii::app()->setComponent('editable',$component);

    }

Or in the config main.php

'editable' => array(
            'class' => 'editable.EditableConfig',
            'form' => 'bootstrap',        //form style: 'bootstrap', 'jqueryui', 'plain' 
            'mode' => 'popup',            //mode: 'popup' or 'inline'  
            'defaults' => array(              //default settings for all editable elements
                'emptytext' => 'Click to edit'
            )
        ),

@surfer190
Copy link
Author

@Julian-B90 Excellent, Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants