Reputation: 603
I am using Angular along with UI-Grid (http://ui-grid.info/)
I have setup the Grid using the options below
this.mdGridLogOptions.gridOptions= {
enableSorting: false,
enableColumnMenus: false,
enableAutoFitColumns: false,
paginationPageSizes: [25, 50, 100, 200, 500],
enableFiltering: true,
enableGridMenu: false,
enableCellEditOnFocus: true,
columnDefs: [
{
field: 'override_date',enableCellEdit:true,
displayName: 'PROMISE DATE', type: 'date',
cellFilter: 'date:"MMM-dd-yyyy"',
cellTemplate:'<div class="ui-grid-cell-contents" layout="row" layout-align="space-between end"><div>{{COL_FIELD CUSTOM_FILTERS}}</div><div ng-click="grid.appScope.clickHandler()" class="material-icons md-light">event</div></div>',
editableCellTemplate: '<div uigriddatepicker ng-class="colt + col.uid"></div>'}}
The field shows properly as below. I have couple of problems
Upvotes: 1
Views: 3589
Reputation: 806
I wanted to do the same thing today, it appears there is no "normal" way to do this, you need to simulate the "dblclick" event on the cell that you need to start editing.
So first in your cellTemplate you need to send the "row" as a parameter to the click handler function.
ng-click="grid.appScope.clickHandler(row)"
later in the clickHandler you need to find out the index of the clicked row and then get the html element of the cell the you want to start editing.
scope.clickHandler = function(row){
// this is a hack to make possible editing on cell by button click
// get the row index of the clicked element
var rowIndex = row.grid.renderContainers.body.visibleRowCache.indexOf(row);
// then get the jqLite element of the cell that needs to be edited
var el = angular.element(document.querySelectorAll('.ui-grid-row')[rowIndex].children[0].children[0]);
// simulate double click on the cell to start editing
el.triggerHandler('dblclick');
};
Upvotes: 1
Reputation: 1
if we use celltemplate then single click event for edit is not work. try any other way to show your data instead of using celltemplate.i think we have cellfilter,directive use below link http://brianhann.com/6-ways-to-take-control-of-how-your-ui-grid-data-is-displayed/
Upvotes: 0