DHTMLX Grid calling function on click of button

Hi,
I am working on Angularjs application. In that I write a button in controller that is :
propValue = “<button title = "{{‘Add’ | translate}}" class = ‘btn btn-xs btn-primary’ onclick = ‘openSaveRelAttr(item.properties.UID)’ >” +
”;

So that this button I am able to see in each row of DHTMLX grid of my page.
In this , on click of this button I have to call the function openSaveRelAttr(item.properties.UID).

I write this function as follows: $scope.openSaveRelAttr = function (connectedUID) {
$stateParams.relUID = $scope.relUID;
$stateParams.relName = $scope.relName;
$stateParams.connectedUID = connectedUID;
$stateParams.className = $scope.className;
$uibModal.open({
animation: true,
controller: “itemDetailsCtrl”,
controllerAs: “$itemDetailsCtrl”,
templateUrl: “app/item/itemdetails/relationshipAttributeModal.html”,
size: “lg”,
backdrop: ‘static’,
resolve: {
items: function () {
return $scope.items;
}
}
});
};

But by Clicking on the button Uncaught ReferenceError: openSaveRelAttr is not defined
at HTMLButtonElement.onclick (localhost/:1) this error occurs.

So, how to call a function on clicking on this button. Please explain me with code.
I have attached the demo, please go through it.

Please see updated Demo

​In this I used attachEvent on “OnRowSelect” and call the function.
Here, I used “OnRowSelect” so when I click on button or any other part of row it will call the function, so for this I used “onButtonClick” event but it is not working. I only want , on click of button I have to call the function. So, please explain me how to use"onButtonClick" event for calling function on button click.

I attached updated demo please go through it

Hii,
I try to write a function outside the controller function, but the $scope variables are not accessible outside the controller function. So, that things are not working here.Please tell me how to access $scope variables outside the controller.
DHTMLXDemo_updated.tar.gz (660 KB)
DHTMLXDemo (2).tar.gz (660 KB)
DHTMLXDemo.zip (661 KB)

But by Clicking on the button Uncaught ReferenceError: openSaveRelAttr is not defined
Seems like your openSaveRelAttr function is not defined, or it is defined out of reach for your onclick event.

Hi,
Function is defined in controller itself, and Button code also written in controller for displaying it on grid.
I write function in scope of button then also function is not call. Please explain me with code having button written in controller and function call on that button.

Your test() function is defined inside the angular module controller function.
Please, try not to place the functions inside the other functions.

[code]angular.module(‘myapp’,[]).controller(‘controller1’,function(){
console.log(‘Inside controller1’);

mygrid = new dhtmlXGridObject('gridbox');
action = "<button title = \"{{'Add' | translate}}\" class = 'btn btn-xs btn-primary' onclick = 'test()' >ADD</button >";

//the path to images required by grid
mygrid.setImagePath("./codebase/imgs/");
mygrid.setHeader(“Sales,Book title,Author,Price”);//the headers of columns
mygrid.setInitWidths(“100,250,150,100”); //the widths of columns
mygrid.setColAlign(“right,left,left,left”); //the alignment of columns
mygrid.setColTypes(“ro,ed,ed,ed”); //the types of columns
mygrid.setColSorting(“int,str,str,int”); //the sorting types
mygrid.init(); //finishes initialization and renders the grid on the page
data = {
rows: [
{ id: 1, data: [action, “A Time to Kill”, “John Grisham”, “100”] },
{ id: 2, data: [action, “Blood and Smoke”, “Stephen King”, “1000”] },
{ id: 3, data: [action, “The Rainmaker”, “John Grisham”, “-200”] }
]
};
mygrid.parse(data, “json”);
});
function test(){
alert(“HI,test”);
}[/code]

I am facing same issue. If I declare function outside controller then it works fine but in that case I could not access variables (like $scope, $stateparams, factoryClass) inside my function. I need a way to use DHTMLXgrid inside Angular so that I can leverage all functionalities provided by Angular.

Please, refer to the solution from my previous post.