Skip to content Skip to sidebar Skip to footer

Devextreme Datagrid Command Button

I am using devextreme grid view. is there any way to add a custom command button besides defualt command button? i have tried this code but i think this is not the correct way. on

Solution 1:

You can do it using html and jquery

$(document).ready(function () {
    var r = $('<label class="className" type="button" onclick="yourFunction()" >Custom Name</button>');
    $('#gridId.dx-toolbar-before').append(r);
});

Solution 2:

I understand you are looking for something like this code.

onContentReady: function (e) {
            if (!e.component.detayColumnAdded) {
                e.component.detayColumnAdded = true;
                e.component.addColumn({
              cellTemplate: function (cellElement, args) {
             $('<a/>').addClass('dx-link')
           .text('Detay')
           .on('dxclick', function (info) {
                        }).appendTo(cellElement)
                    }
                });
            }

        }

Also

columns: [
           { cellTemplate: function (container, options) {
            $('<a/>').addClass('dx-link')
            .text('CLÄ°CK')
            .on('dxclick', function (info) {

            })
            .appendTo(container);
      }
  }

Solution 3:

I'm implementing workaround in angular: adding a normal column and change template

<dxi-columncellTemplate="cellTemplate"caption="Edit"...><div *dxTemplate="let cell of 'cellTemplate'"><div><iclass="fa fa-edit"></i></div></div></dxi-column>

then catch wit onCellClickevent:

onCellClicked = (e): void => {
 if (e.column.caption === 'Edit') {
   this.OpenMobile.emit(e.data);
   return;
 }
}

read more about cellTemplate

and onCellClick

so you can implement this useful trick whatever the framework.

Post a Comment for "Devextreme Datagrid Command Button"