How to truncate value in yii2 kartik editable option

You possibly use the following in your view

use kartik\grid\GridView;
use kartik\dynagrid\DynaGrid;
use kartik\dynagrid\DynaGridStore;
use kartik\editable\Editable;
use kartik\select2\Select2 ;
use yii\widgets\Pjax;
use kartik\cmenu\ContextMenu;

You will also need use also the one below. This contain truncate function.


So in your view you might have the following under the column definition

‘class’ => ‘kartik\grid\EditableColumn’,
‘editableOptions’=> function ($model) use ($customerFilter) {
return [
‘format’ => ‘link’,
‘asPopover’ => true,
‘displayValueConfig’ => $customerFilter,  //This is where your value is displayed
‘inputType’ => Editable::INPUT_SELECT2,
‘theme’ => ‘krajee’,
‘data’ => $customerFilter,
‘allowClear’ => true,

then do the following:

replace the displayValueConfig with displayValue

//’displayValueConfig’ => $customerFilter,  //This is where your value is

then add necessary things and use your filter array.

This will truncate a value nicely to 30 characters and display all characters on hover.

‘displayValue’ => Html::a(StringHelper::truncate($customerFilter[$model->company_id], 30, $suffix = ‘…’),[‘tickets/view’,’id’ => $model->ticket_id], [

Hope you enjoy it and let me know if you need any more help with this 🙂


How to fix TypeError: jQuery(…).editable is not a function in yii2 kartik editable gridview issue

You could have a problem described below

This has been copied from

I am having a problem with the editable column in a gridview, I was hopingfor a point in the right direction to resolve. When I add a row in a blank grid via ajax, I reload the grid using pjax. On the Pjax reload the editable column comes up as a button and has no events triggered. Firebug reports the following error.

TypeError: jQuery(…).editable is not a function.

On a page reload after adding the first row everything works as expected. Adding a second line to the grid everything works as expected. The problem only occurs when the first row is added and the grid refreshed via pjax.

This can be fixed by loading the assets manually .

Just put this on the top of your view and it will work fine.

use kartik\editable\EditableAsset;


use kartik\editable\EditablePjaxAsset;


use kartik\popover\PopoverXAsset;


I have also reported it kartik here where more info can be found regards this issue.

Have a happy Yii2 programming!