Hi,I am displaying panels in dashboard from database, In panel header I want to show an icon and on click of that icon I want to call a function, but doing my way I am getting function name as undefined, below I am sharing my code lines-------------component code-----------------this._DashboardService.GetDesigningDashboard(this.UserRoleId, this.ProjectId, this.LoggedInEntityType, this.LoggedInEntityId).subscribe(data => {this.panels = JSON.parse(data);setTimeout(function () {let closeElement = document.querySelectorAll(".classXYZ");for (let i = 0; i < closeElement.length; i++) {closeElement[i].addEventListener("click", this.onCloseIconHandler.bind(this)); //undefined}}, 100);}-----------html----------------------<ejs-dashboardlayout id='default_dashboard' columns="5" #default_dashboard [cellSpacing]='cellSpacing' [allowResizing]='true' [panels]='panel' ><e-panels><div *ngFor="let panel of panels"><e-panel [sizeX]="panel.sizeX" [sizeY]="panel.sizeY" [row]="panel.row" [col]="panel.col" [header]="panel.content"></e-panel></div></e-panels></ejs-dashboardlayout>-----------console value------------------------------console value of panel, getting from db
- 0:
- col: 0
- content: "<div class="classXYZ"><a><img src="./assets/flex-images/Delete_1.png" alt="ToolTip" title="Delete Component"/></a></div>"
- id: 5
- row: 0
- sizeX: 1
- sizeY: 1
- please help
|
created(args) {
var proxy = this;
let closeElement = document.querySelectorAll(".classXYZ");
for (let i = 0; i < closeElement.length; i++) {
closeElement[i].addEventListener(
"click",
proxy.onCloseIconHandler.bind(this)
); //undefined
}
} |
|
created(args) {
var proxy = this;
let closeElement = document
.getElementById("panel3")
.querySelector(".classXYZ");
let closeElement1 = document
.getElementById("panel4")
.querySelector(".classXYZ");
closeElement.addEventListener("click", proxy.onCloseIconHandler.bind(this));
closeElement1.addEventListener("click", proxy.second_function.bind(this));
}
|
Hi RakhiS,Sorry for the inconvenience.Based on the shared details, we are unable to identify the exact use case of your reported issue. We have created a sample with page navigation similar to your scenario, but the issue is not reproduced in our end and the provided code works finePlease, refer to the below sample.Please, share the below details to proceed further with your reported problem.1. Share us a video footage on the reported issue.2. Exact use case of your reported problem.3. If possible, replicate the issue in attached sample.4. Share us the steps to replicate your reported problem in the above sample.Please let us know, if you need any further assistance.Regards,Sowmiya.P
|
this.dashboardObject.addPanel(panel[0]);
let closeElement = document
.getElementById(this.count.toString())
.querySelector('.classXYZ');
closeElement.addEventListener('click', this.onCloseIconHandler.bind(this)); |
Hi RakhiS,We checked with your reported query and the video attachment. Based on the video, we understand that the dialog had opened only for the first click of the icon and this doesn’t works after page navigation. We suspect that the event binding for the icon wouldn’t have taken place properly while adding the panels. So, we suggest you to bind the event listener after adding the panels. In the sample given we have rendered panels initially, similar to the previous sample. And a panel has been added dynamically with same close icon with required event binding.Please refer to the code snippet below.
this.dashboardObject.addPanel(panel[0]);let closeElement = document.getElementById(this.count.toString()).querySelector('.classXYZ');closeElement.addEventListener('click', this.onCloseIconHandler.bind(this));Kindly check with the sample similar to your scenario.If the issue persists in your end, please modify the above sample so as to reproduce your exact issue so that we can assist you promptly.Regards,Sharon Sanchez S.
Hi RakhiS,We checked with your reported query and the video attachment. Based on the video, we understand that the dialog had opened only for the first click of the icon and this doesn’t works after page navigation. We suspect that the event binding for the icon wouldn’t have taken place properly while adding the panels. So, we suggest you to bind the event listener after adding the panels. In the sample given we have rendered panels initially, similar to the previous sample. And a panel has been added dynamically with same close icon with required event binding.Please refer to the code snippet below.
this.dashboardObject.addPanel(panel[0]);let closeElement = document.getElementById(this.count.toString()).querySelector('.classXYZ');closeElement.addEventListener('click', this.onCloseIconHandler.bind(this));Kindly check with the sample similar to your scenario.If the issue persists in your end, please modify the above sample so as to reproduce your exact issue so that we can assist you promptly.Regards,Sharon Sanchez S.
Hi Sharon, thanks for your reply. I tried with the same example you gave, but still facing the same issue. Then I found that th eonly diffrence in your and mine sample code is, I am bringing panels info from backend in json format and assign in front end by doing json.parse and in html like the following way :sql code :you can see I am creating the header from sql while rendering my panels.and while adding doing the same thing that you suggested.:so while adding clicking is working fine, but only rendering giving problem. I hope u understand. please reply